needleinthehay.de

Housekeeping Git Branches

Clean up local branches

  1. List all local:

    git branch
  2. List merged:

    git checkout main
    git branch --merged
  3. Remove all outdated branches with:

    git branch -d <old-merged>
  4. List not merged:

    git branch --no-merged
  5. Force remove abandoned (careful!):

    git branch -D <old-abandoned>

Clean up references to remote branches

  1. List all remote:

    git branch -r
  2. Prune staled remote branches:

    git fetch -p