Skip to content

Instantly share code, notes, and snippets.

@RoboWeb
Last active April 19, 2018 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoboWeb/f7093bc951175bdb4832d69aff4014b4 to your computer and use it in GitHub Desktop.
Save RoboWeb/f7093bc951175bdb4832d69aff4014b4 to your computer and use it in GitHub Desktop.
How to remove branches

Deleting git branches

If you want more detailed explanations of the following commands, then see the long answers in the next section.

Deleting a remote branch:

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

Deleting a local branch:

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

Deleting a local remote-tracking branch:

git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter

git fetch <remote> --prune # Delete multiple obsolete tracking branches
git fetch <remote> -p      # Shorter

More here: https://stackoverflow.com/a/23961231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment