When to delete a branch from Git?
Nuke it from orbit. You only really have to care when your delete will remove stuff that isn't in the history of your head branch... and even then I do that quite often if I started testing something and decided it was worthless.
Delete topic branches (like "fix-iss05") as soon as you merge them back into your master or development branch. Depending on your workflow, you may want to do all work and merges on a "development" branch, and only merge changes to master after they've been tested and are ready to release.
For a great read on git workflow, check out: http://geewax.org/2009/11/21/agile-git-workflow.html
As I see it, there's really no need to keep it around. Unless you --squash
the merge, you will have that branch's history in master. I'd go ahead and delete ones you no longer need.
Typically, you delete a branch after a merge.
For example, after the following merge, you would delete the branch iss53
, as you don't need to develop from that branch anymore. You can later recreate it at any moment using the sha1 value of the commit by git checkout -b <name> <sha1>
.
(Branches are only necessary when they point to commits that are "tips" of the tree. In fact, in that case, git won't let you remove it, unless you force it to.)
(the image above comes from the excellent progit book)