Summary
Gits branches are so lightweight that its easy to create them whenever you better.
But its also easy to end up with leftover branches you no longer need.
So whats involved in deleting a branch?
Maksim Safaniuk/Shutterstock
Why Delete a Branch?
This is fine since branching is a lightweight operation; its very fast and uses disk space efficiently.
As a result, many git development workflows encourage branching, even for very small or short tasks.
For example, a common strategy is tocreate a separate branchfor each and every bug fix.
Deleting branches should be just as much a part of your everyday workflow as creating them is.
Therefore, git will refuse to delete such a branch by default.
Youll use thegit pushcommand along with the-dflag to delete.
maineven though git itself supports this.
If the default branch is the one that is currently active, the app disables the menu action.
You must delete each separately.
Hover over the appropriate branch name and click theBranchactions menu which looks like three vertical dots.
The app displays local and remote branches in a panel on the left-hand side.
As with the GitHub Desktop app, the GitHub website will not allow you to delete the default branch.
If you try, youll see an warning pop-up:
Deleting any other branch, however, is straightforward.
However, since it will always represent a remote branch, this behavior should make sense.
Note that, after deleting, youll see a button toRestorethe branch.
However, this is simply a useful undo feature, just in case you poke the delete icon accidentally.
Bitbucket calls this theMain branchinRepository controls.
But for simple day-to-day development, youre likely to be creating and deleting local branches all the time.
This is a core aspect of a typical git workflow you should become accustomed to.