Skip to content

Instantly share code, notes, and snippets.

@nicholashoule
Last active March 24, 2024 23:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicholashoule/ff5a00c8f02ea57f0b26889f022620f4 to your computer and use it in GitHub Desktop.
Save nicholashoule/ff5a00c8f02ea57f0b26889f022620f4 to your computer and use it in GitHub Desktop.
Git prune and delete merged local branches

Git prune and delete merged local branches

Prune
git remote prune origin --dry-run
git remote prune origin
Delete (Bash)
git branch --merged | grep -v \*
git branch --merged | grep -v \* | xargs git branch -D 
Delete (Powershell)
git branch --merged | Select-String -Pattern '\*' -notMatch
git branch --merged | Select-String -Pattern '\*' -notMatch |  % { $_.split()[0] } | % { git branch -D $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment