Skip to content

Instantly share code, notes, and snippets.

@Raywire
Forked from nicholashoule/gitbranches.md
Created November 27, 2023 13:13
Show Gist options
  • Save Raywire/fe88dc7a0977ef797b178123c6acc469 to your computer and use it in GitHub Desktop.
Save Raywire/fe88dc7a0977ef797b178123c6acc469 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