Skip to content

Instantly share code, notes, and snippets.

@nicholashoule
Last active September 20, 2024 16:25
Show Gist options
  • 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