Skip to content

Instantly share code, notes, and snippets.

@ffMathy
Last active March 21, 2023 09:55
Show Gist options
  • Save ffMathy/721806d92be6939e7b14681165632909 to your computer and use it in GitHub Desktop.
Save ffMathy/721806d92be6939e7b14681165632909 to your computer and use it in GitHub Desktop.
Cleans up branches that have been merged in to either develop or master remotely.
powershell.exe -Command "git fetch --all; git branch --merged | ForEach-Object { $_.Trim() } | Where-Object {$_ -NotMatch \"^\*\"} | Where-Object {-not ( $_ -Like \"*master\" -or $_ -Like \"*main\" -or $_ -Like \"*develop\" )} | ForEach-Object { git branch -d $_ }; git fetch --all; git remote prune origin; git fetch --all"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment