DEV Community

Discussion on: 15 Git Commands You May Not Know

Collapse
 
diogotome profile image
Diogo Tomé

In my workflow it is routine to delete branches on Github Pull Requests when they're merged. This leaves the local repo with local branches that have since lost its tracking branch. To clear this I have the following alias under .gitconfig

prune-branches = !git remote prune origin && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D

So whenever a bunch of my PR's have been merged I just run git prune-branches and it prunes the remote branch references but also deletes the corresponding local ones.