Last active
August 30, 2022 01:45
-
-
Save goliney/69358109654bd35fced1236e8d372ba0 to your computer and use it in GitHub Desktop.
Terminal shortcuts for clearing local git 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
# delete all git branches except main | |
function delete_all_branches_git() { | |
git checkout main | |
git branch | grep -v "main" | xargs git branch -D | |
} | |
# delete all git branches which start with prefix (except main) | |
function delete_branches_by_prefix_git() { | |
git checkout main | |
git branch | grep -v "main" | grep "$1" | xargs git branch -D | |
} | |
# delete fetched branches. Change "serhii/" to your own prefix | |
function delete_not_mine_branches_git() { | |
git checkout main | |
git branch | grep -v "main" | grep -v "serhii/" | xargs git branch -D | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment