git fetch prune 1

git fetch prune

git fetch --prune #is the best utility for cleaning outdated branches. It will connect to a shared remote repository remote and fetch all remote branch refs. It will then delete remote refs that are no longer in use on the remote repository

Here is what the above code is Doing:
1. git fetch –prune
2. git branch -r | awk ‘{print $1}’ | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d git branch -r | awk '{print $1}' This will list all remote branches. egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) This will list all local branches that are tracking a remote branch. awk '{print $1}' This will print the first column of the previous command, which is the name of the local branch. xargs git branch -d This will delete all local branches that are not tracking a remote branch.

Similar Posts