Skip to content

Instantly share code, notes, and snippets.

@gt11799
Last active June 13, 2016 09:35
Show Gist options
  • Select an option

  • Save gt11799/1846c7f026044b518a8b8221a744860d to your computer and use it in GitHub Desktop.

Select an option

Save gt11799/1846c7f026044b518a8b8221a744860d to your computer and use it in GitHub Desktop.

Clean Out All Local Branches

Sometimes a project can get to a point where there are so many local branches that deleting them one by one is too tedious. This one-liner can help:

$ git branch --merged master | grep -v master | xargs git branch -d

This won't delete branches that are unmerged which saves you from doing something stupid, but can be annoying if you know what you are doing. If you are sure you want to wipe everything, just use -D like so:

$ git branch --merged master | grep -v master | xargs git branch -D

delete remote branch

git br -r | grep 'origin/' | grep -v "master\|sy_score\|update-customer" | awk -F '[/]' '/origin/ {printf":%s\n",$2}' | xargs git push origin 

source

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