Skip to content

Instantly share code, notes, and snippets.

@afsardo
Last active January 30, 2018 22:23
Show Gist options
  • Save afsardo/80f6c33c2a1571969600b6d8ec5fcba9 to your computer and use it in GitHub Desktop.
Save afsardo/80f6c33c2a1571969600b6d8ec5fcba9 to your computer and use it in GitHub Desktop.
Delete old branches

When you are working in a team, you often make branches for features/bugs. After the branch gets merged into master, you end up with an old reference in your own git history.

If you are like me, that although knowing git in the command line, use the Github Desktop app, you end up with an infinite list of old branches.

Heres the one single command solution:

$ git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d

Reference: http://erikaybar.name/git-deleting-old-local-branches/

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