

They are completely separate objects in Git.Įven if you've established a tracking connection (which you should for most scenarios), this still does not mean that deleting one would delete the other, too! Just a side note: please keep in mind that local and remote branches actually have nothing to do with each other. But be careful with this as you might lose data. '-D' option is the combination of '-delete' and '-force' to forcefully delete the local branch. As mentioned in the output of the command we ran, you need to use the '-D' option to delete the local branch which is not fully merged.
GIT DELETE BRANCH LOCALLY AND REMOTELY CODE
Deleting both a local and a remote branch If you work with remote-tracking branches, then to find and delete them, you must run the git branch command with the -remote or -r attributes. Quick Links Why Delete Branches Delete Local Branch Delete Remote Branch Automatically Deleting Github Pull Request Branches Branches are a core part of Git workflows, being used to keep unfinished code out of the master codebase. If you are sure you want to delete it, run git branch -D my-branch. In fact, nearly everything can be reverted by using this convenient keyboard shortcut. That's not the only Git operation you can undo in Tower.

But even better: if you made a mistake, you can simply hit CMD+Z (or CTRL+Z on Windows) to undo the deletion and restore the branch! In case you are using the Tower Git client, you can simply right-click any branch item in the sidebar and choose the "Delete…" option to get rid of it.
