Skip to content

Instantly share code, notes, and snippets.

@AdamPrendergast
Last active May 12, 2026 09:05
Show Gist options
  • Select an option

  • Save AdamPrendergast/24f1e300e922b57d6b22b5c119df6e07 to your computer and use it in GitHub Desktop.

Select an option

Save AdamPrendergast/24f1e300e922b57d6b22b5c119df6e07 to your computer and use it in GitHub Desktop.
Git Helpers
// Check which branches have **not** been merged
git branch --no-merged main
git branch --no-merged develop
// Check which branches have been merged
git branch --merged main
git branch --merged develop
// Delete all local branches that have been merged to 'main'
git branch --merged main | Select-String -Pattern "^(\s*)(?!.*(\*|main)).*$" | ForEach-Object { $_.Matches.Groups[0].Value.Trim() } | ForEach-Object { git branch -d $_ }
// Delete all local branches that have been merged to 'develop'
git branch --merged develop | Select-String -Pattern "^(\s*)(?!.*(\*|develop)).*$" | ForEach-Object { $_.Matches.Groups[0].Value.Trim() } | ForEach-Object { git branch -d $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment