I want to delete a branch both locally and remotely.
$ git branch -d
For deleting the remote branch:
git push origin --delete
For deleting the local branch, you have three ways:
1: git branch -D
2: git branch --delete --force # Same as -D
3: git branch --delete # Error on unmerge
Explain: OK, just explain what's going on here!
Simply do git push origin --delete
to delete your remote branch only, add the name of the branch at the end and this will delete and push it to remote at the same time...
Also, git branch -D
, which simply delete the local branch only!...
-D
stands for --delete --force
which will delete the branch even it's not merged (force delete), but you can also use -d
which stands for --delete
which throw an error respective of the branch merge status...
I also create the image below to show the steps: