git remove deleted remote branches 1

git remove deleted remote branches

git fetch origin --prune

Here is what the above code is Doing:
1. git fetch origin –prune
– This will fetch all the branches from the remote repository.
– The –prune flag will remove any branches that have been deleted from the remote repository.
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 - This will delete all the local branches that have been deleted from the remote repository. - The first part of the command will get all the remote branches. - The second part of the command will get all the local branches that are tracking the remote branches. - The third part of the command will get all the local branches that are not tracking the remote branches. - The fourth part of the command will delete all the local branches that are not tracking the remote branches.

Similar Posts