Created
April 9, 2019 09:20
-
-
Save junderw/bf746e0a721e8a1a85d5cadbd2519a9f to your computer and use it in GitHub Desktop.
Some commands for cleaning up my git folders... too many branches over time.
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
# Get rid of remotes | |
git fetch --prune --all | |
# Check branches for stuff you might want to keep | |
# This will show branches that are NOT on the remote for origin or upstream | |
git branch | grep -v "$(git branch --remote | grep -e "origin/\|upstream/" | grep -v "\->" | cut -d/ -f2)" | |
# Here's another one to check. checks your local master and gives any branches that are merged to master | |
git branch --merged=master | grep -v master | |
# Get rid of local branches not on origin or upstream | |
# WARNING THIS MIGHT LOSE YOUR WORK, CHECK THE ABOVE FIRST | |
git branch -D $(git branch | grep -v "$(git branch --remote | grep -e "origin/\|upstream/" | grep -v "\->" | cut -d/ -f2)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment