Skip to content

Instantly share code, notes, and snippets.

@sganous
Last active June 9, 2021 18:37
Show Gist options
  • Save sganous/ccfcd475e529f3c3b90ab6c4fd685a0c to your computer and use it in GitHub Desktop.
Save sganous/ccfcd475e529f3c3b90ab6c4fd685a0c to your computer and use it in GitHub Desktop.
Local git branch cleanup
git branch --merged | grep -v "master" >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
@sganous
Copy link
Author

sganous commented Jun 9, 2021

  • Save list of 'merged' branches into tmp file (excluding master)
  • Quick review of the tmp file to confirm branches
  • Delete local branches saved in file

Quick add to alias:
git config --global alias.purge '!git branch --merged | grep -v "master" >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment