Skip to content

Instantly share code, notes, and snippets.

@ismyrnow
Last active October 12, 2022 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismyrnow/6f5a4ae1e2ce9d66892af59bf7d0c97e to your computer and use it in GitHub Desktop.
Save ismyrnow/6f5a4ae1e2ce9d66892af59bf7d0c97e to your computer and use it in GitHub Desktop.
Cleanup Git Branches

Delete merged branches

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

Delete local refs to remote branches that no longer exist

git fetch --prune

Delete remote refs that are no longer in use, leaving local refs in place

This might be more conservative than git fetch --prune.

git remote prune origin

Cleanup, including pruning unreachable commits

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