How to delete/prune old local git branches
When you delete a branch with git, and push those changes, you might see that your local repo still has that branch in the list
1 |
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d |
What this basically does is fetch all the branches and all the ones with a ‘gone’ attribute, (meaning deleted remotely), then we will remove them.
You can view the branches and what their attribute is yourself by typing
1 |
git branch -vv |
Of course, you need to prune
the branches on the remote git server
1 |
git remote prune origin<br> |
To make sure all is good, just re-list your branches, (local and remote)
1 |
git branch --vv -a |
Recent Comments