Skip to content

Instantly share code, notes, and snippets.

@cmatskas
Last active September 22, 2022 07:59
Show Gist options
  • Save cmatskas/454e3369e6963a1c8c89 to your computer and use it in GitHub Desktop.
Save cmatskas/454e3369e6963a1c8c89 to your computer and use it in GitHub Desktop.
Git Delete Branch commands
## Delete 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
## Delete a local branch
$ git branch --delete <branch>
$ git branch -d <branch> # Shorter version
$ git branch -D <branch> # Force delete un-merged branches
## Delete 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
@soiqualang
Copy link

Many thanks!

@manojkumarkhedkar
Copy link

thanks

@GllmN
Copy link

GllmN commented Mar 6, 2021

thanks

@hungle965
Copy link

tks bro

@HyrumDickinson
Copy link

tkrl6cbb

@letrung2719
Copy link

good man

@chris-chameleonbrands
Copy link

thx :)

@Jmzgit
Copy link

Jmzgit commented Oct 31, 2021

Beautiful...wrapping up w branch deletion after a checkout commit history run. tnx

@yutjifuki
Copy link

tq

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