Last active
December 1, 2017 19:39
-
-
Save dwenaus/a045cfd5e76f16162a8c69c09de65615 to your computer and use it in GitHub Desktop.
a quick way to clean-up local branches which no longer exist remotely
This file contains 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
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -n 1 git branch -d | |
the above command will show which will be deleted. use -D instead of -d to delete them all | |
tested and works | |
does not delete local branches which only exist locally and have never existed remotely. | |
a better version would test whether the branch creates a diff or pr. ie. it's been merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment