If you didn't push the branch to the remote, you can simple delete it locally:
git branch -d my_branch
Note: git will refuse to delete the branch if you have not merged it into its upstream or the current branch, to save you from losing the commits in the branch. If you are certain you do not need the commits, you can force the deletion with git branch -D my_branch
.
You can get an overview of all branches by typing:
git branch -a
This may give something like the following:
* master
my_branch
remotes/origin/master
(The branch with *
is your current branch)
Note that the remote 'origin' doesn't have the local branch my_branch
, since you haven't pushed it yet. Even if you had added and committed on the branch locally, it wouldn't be on the remote (until you push it).
If you did push it, you can remove it from the remote as follows:
git push origin :my_branch