Skip to content

Instantly share code, notes, and snippets.

View wyeo's full-sized avatar
👋

Williams YEO wyeo

👋
View GitHub Profile
@wyeo
wyeo / Remove_local_branches.md
Last active April 24, 2020 11:39
Remove unsed git local branches

One-line command

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

  • git branch –merged : first, you are simply listing all the branches currently merged with your current checked out branch;
  • egrep -v “(^*|master|dev)” : you are using the invert matching feature of grep in order to exclude any branches that may be called “master” or “dev”, just in case;
  • xargs git branch -d : you are deleting every single branch listed before.

Source