1

I want to go over all dead branches in my repo, and delete them. On bitbucket it seems I only have about 15 "floating" branches but git branch -a | wc -l shows about 70...

Does git branch -a shows dead branches or branches that are somehow not pushed upstream? (I don't believe this to be the case, as git branch gives only 3 branches on my local machine)

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124

1 Answers1

3

Git is always very careful to never delete or overwrite any information without being expressly told to do so. In this case, there are likely branches which have been deleted from bitbucket's copy of the repository, but which are still kept on your local copy. Running a git fetch by default will only download new branches, but not delete them if they are deleted on the server. For that, you will want to use git fetch --prune.

This will only delete the remote-tracking branches (i.e. origin/branch-name), so you will still want to prune your local branches.

See: How to prune local tracking branches that do not exist on remote anymore

UnderSampled
  • 131
  • 6