Today learned about local-remote tracking branches and how to keep the local output of
git branch -a
clean from obsolete branches. Found useful information on stackoverflow and collected into my wiki. What you see in the output of the above command are local branches, which you may commit to directly and so called local-remote tracking branches.
You should use the git branch command to delete local branches and the git push command to delete remote branches and its local-remote tracking counter parts.
git branch -d # Delete merged branch
git branch -D # Force delete un-merged branch
git push origin --delete xxx # Delete remote branch xxx
But if you already delete the remote branch at remote side, e.g. at github’s web-interface, than you get rid of the now obsolete remote-tracking branch by:
git branch -dr xxx # Delete remote-tracking branch xxx
git fetch origin -p # Delete all obsolete remote-tracking branches
See my wiki for more details!
Generally, you should keep the number of branches for different features or bug fixes small in your repositories. Once you finished your work on a feature or bug fix branch, then maybe another developer will make code-review and a merge to master branch. After a merge has been done, it’s common to delete the feature or bug fix branch.