Created
September 18, 2021 18:54
-
-
Save idan/f9543c9068c5caf9622d6d8efadb4c2c to your computer and use it in GitHub Desktop.
A fish function which deletes all branches not called main or master
This file contains hidden or 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
function branchclean | |
# delete branches that are not called 'main' or 'master' | |
# Invoke with -r to also delete the branches on the origin remote | |
# WARNING — this doesn't check if the branches are merged. | |
argparse 'r/remote' -- $argv | |
for b in (git branch | grep -v "^\*\?\s\+\(master\|main\)\$" | string trim); | |
git branch --delete $b; | |
if test -n "$_flag_r" | |
git push -d origin $b | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment