If you want to delete a branch both local and remote how do you do this? You might need to delete local and remote or remote local branches in git that you do not want to use any more after git pull.

Let’s use the following commands that will do your task easy.

Gir Remote Branch-

You can delete the remote branch using following command-

git push origin --delete <branch>  # Git version 1.7.0 or newer
git push origin -d <branch>        # Shorter version (Git 1.7.0 or newer)
git push origin :<branch>          # Git versions older than 1.7.0

Gir Local Branch-

You can delete the Local branch using following command-

git branch --delete <branch>
git branch -d <branch> # Shorter version
git branch -D <branch> # Force-delete un-merged branches

Local Remote Branch

To delete the Remote Local branch use following command-

git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter
git fetch <remote> --prune # Delete multiple obsolete remote-tracking branches
git fetch <remote> -p      # Shorter