git prune remote branches code example
Example 1: git clean local remote branch
git fetch origin --prune
Example 2: git remove deleted remote branches
git fetch origin --prune
Example 3: git prune local branches
# for pruning of local branches that have been deleted on remote
git remote prune origin
# for checking local branches and if they can be deleted
# because they have been merged into another branch already
git branch --merged >/tmp/merged-branches && \
vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
Example 4: git prune remote branches
git remote prune origin
Example 5: remove old remote branches git
git remote prune origin
Example 6: git prune local branches
npx git-removed-branches --prune