Last active
February 12, 2021 20:31
-
-
Save irontoby/3f62f9eac2a0d00e4a42939ff4f81ca5 to your computer and use it in GitHub Desktop.
Git "Deep Clean"
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
#!/bin/bash | |
# does a better job of cleaning unreachable stuff | |
git reflog expire --expire-unreachable=2.weeks.ago | |
git gc --prune=now |
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
#!/bin/bash | |
echo Removing local branches which have already been merged at remote... | |
git-purge-remote-merged.sh | |
echo Removing local branches which were created to track remotes, when remote is now gone... | |
git-remove-local-with-pruned-remote.sh | |
echo Deep prune... | |
git-better-clean.sh |
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
#!/bin/bash | |
# remove local branches which have already been merged at remote | |
git remote prune origin | |
git branch --merged | egrep -v "(^\*|master|main|dev|core|hotfix)" | xargs --no-run-if-empty git branch -d |
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
#!/bin/bash | |
# remove local branches which were created to track remotes, when remote is now gone | |
git branch -vv | perl -ne 'print unless m/^[+*]/;' | grep ': gone]' | tee /dev/tty | awk '{print $1}' | xargs --no-run-if-empty git branch -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment