Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Git pruning?

I've accidentally pruned some remote branches and I don't really know what the consequence of this is (I clicked the "Prune remote branches" button in Git Extensions, thinking it would delete a remote branch).

The official documentation says "git-prune - Prune all unreachable objects from the object database ". I don't really understand what this means. I'm guessing this might have removed merged branches but I'm not really sure.

like image 980
Daniel Ball Avatar asked Mar 18 '16 11:03

Daniel Ball


People also ask

What does git remote update origin -- Prune do?

With --prune , the update process simply removes any remote-tracking names that exist in your repository, but no longer correspond to a branch name in the repository at remote .

How do I trim a git repository?

remove the file from your project's current file-tree. remove the file from repository history — rewriting Git history, deleting the file from all commits containing it. remove all reflog history that refers to the old commit history. repack the repository, garbage-collecting the now-unused data using git gc.

Does git prune delete remote branches?

Delete remote tracking branch in GitThe prune option removes any remote tracking branch in your local repository that points to a remote branch that has been deleted on the server.


2 Answers

"Prune remote branches" in Git Extensions executes git remote prune command, which removes your local remote tracking branches where the branch no longer exists on the remote.

See here: https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-empruneem

Deletes stale references associated with <name>. By default, stale remote-tracking branches under <name> are deleted, but depending on global configuration and the configuration of the remote we might even prune local tags that haven’t been pushed there. Equivalent to git fetch --prune <name>, except that no new references will be fetched.

See the PRUNING section of git-fetch for what it’ll prune depending on various configuration.

With --dry-run option, report what branches would be pruned, but do not actually prune them.

like image 138
1615903 Avatar answered Oct 07 '22 22:10

1615903


This just garbage collects your branches.

Thats means, if an object (a commit) cannot be reached in any of your branch's ancestors, it will be removed for the git database, and as such couldn't be reach anymore.

This just cleans up a little the git repository and make it lighter.

like image 34
blue112 Avatar answered Oct 07 '22 22:10

blue112