Created
June 27, 2019 19:38
-
-
Save get-data-/b3aa18b09ec6433115a8dd161a1bc685 to your computer and use it in GitHub Desktop.
Clean up local branches after they are deleted on remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Look at what will get removed before taking action | |
git remote prune origin --dry-run | |
# Prune and delete those branches locally which were deleted on your remote repository | |
git fetch --prune | |
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment