What is Git pruning?

It's important to know that prune is repo-bound. Not everyone knows that you can link your local repo to multiple remotes. It comes in handy when, for example, you work with an open-source project and is enforced to work via forks.

So, prune command requires a repo name. In most cases it's git remote prune origin, but you can call your repo anything, it doesn't have to be origin.


There may be remote feature branches which are removed after we merge them into master. We might have deleted the feature branches as a way of cleaning up. But if you had checked out the deleted branch to the local system and set to status as tracking, git pull will not delete those local branches (because those are already disconnected from the server). To clean up that kind of local orphan branches, git prune command will come handy to help.


"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.


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.