Last active
May 6, 2022 08:20
-
-
Save eegeeZA/2f680eb9c9372d2d2db839f79ed2cfb9 to your computer and use it in GitHub Desktop.
Clean up unnecessary local and remote branches
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
# WIP # | |
# remove *local* branches merged into origin/master | |
#&"git" branch -d @(git branch --merged origin/master | Select-String -Pattern "^\*|(develop|master)$" -NotMatch) | |
# remove *remote* branches merged into origin/master | |
#&"git" push origin -d @((git branch -r --merged origin/master | Select-String -Pattern ".*(origin/(qa1|qa2|prod)$)" -NotMatch) -Replace " *origin/","") |
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
# remove *local* branches merged into origin/develop | |
git branch --merged origin/develop | egrep -v "(^\*|(develop|master)$)" | xargs git branch -d | |
# remove *remote* branches merged into origin/develop | |
git branch -r --merged origin/develop | egrep -v "(origin/(develop|master)$)" | cut -d "/" -f 2- | xargs git push origin -d | |
# remove all files that should be ignored | |
git rm -r --cached . && git add . | |
# normalise the line endings | |
git add --renormalize . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment