August 31, 2023
blogknowledge
Delete all local orphan branches that has no remote upstream branch
Simple git commands to delete orphan branches that has no upstream remote branch
GIGit
For deleting all local branches that has no remote upstream branch
For Fetching the latest branch list
sh
git fetchFor removing references to all remote branches that are deleted
sh
git remote prune originFor deleting all local branches that has no upstream remote branch
this will still give warning for unmerged branches
sh
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -dFor force deleting all local branches that has no upstream remote branch
sh
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -DRun this in Git Bash, if you are in a windows machine
NOTE: This will also remove any local branch that you created for some of your own purpose