Skip to content

Instantly share code, notes, and snippets.

@ShoGinn
Forked from nicholashoule/gitbranches.md
Created September 20, 2024 16:25
Show Gist options
  • Save ShoGinn/40ee34aec94998c7170e2cd95c91d204 to your computer and use it in GitHub Desktop.
Save ShoGinn/40ee34aec94998c7170e2cd95c91d204 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