Last active
May 12, 2026 09:05
-
-
Save AdamPrendergast/24f1e300e922b57d6b22b5c119df6e07 to your computer and use it in GitHub Desktop.
Git Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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