How do I delete a git branch locally and remotely?

Written on by Sahil Bhatacharya in Solving Mistories

Git branches are important part of you daily development process, but once you or your team are finished with a feature and have merged it into your remote’s master branch, you would want to delete that branch from local repo as well as your remote. You can do it in two ways:

git push --delete <remote_name> <branch_name>

To delete a local branch use the following:

git branch -d <branch_name>


  • -d option for git branch command is an alias of --delete flag, which deletes the branch if it has already merged in its upstream branch.
  • -D is also an option --delete flag, which deletes the branch "regardless of its merged status."

Sign up below to receive updates, tips and more handy tutorials. It’s good stuff & I don’t spam.