Suppose we have an application that\'s stable.
Tomorrow, someone reports a big ol\' bug that we decide to hotfix right away. So we create a branch for that hotfix off o
I would add that the disadvantage of deleting branches is that you will break any hyperlinks to those branches on GitHub (this question is tagged github). You'll get a 404 Not Found
error for those links. This is why I change my links to point to a commit or tag after I delete a branch on GitHub.
Because some links can't be changed, such as in email, I now avoid hyperlinking to GitHub branches entirely and link to a commit or tag from day one.
I prefer to delete branches after they're merged in. This prevents the visual clutter of a long list of branches in your repository. These branches also get propagated to all of the repository's forks.
First I delete my local branch. This prevents it from being accidentally pushed later.
git branch -d branchName
Then I delete the remote tracking branch
git branch -dr remoteName\branchName
Then I delete the branch on GitHub. I use the web interface, but the equivalent command is below.
git push remoteName :branchName
Even if the branch is never merged, typically I would still like to keep the commits around for posterity. However I still like to delete the branch. To spread the commits around and to keep them from being eaten by the garbage collector, I make an annotated tag pointing to the same commit as the deleted branch.
git tag -a tagName commitOrBranchName
Then I push the tag to github
git push remoteName tagName
You can delete branches in all major web UIs such as github, BitBucket. After deleting the branch online, you can delete the local branch using
git remote prune origin