Last active
March 12, 2021 18:25
-
-
Save samuelcolvin/b39536da4eb581da2ad134bea7cd47d3 to your computer and use it in GitHub Desktop.
switch to with master or main
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
gm() { | |
if git branch | grep -q '^[* ]*master$'; then | |
git checkout master | |
else | |
git checkout main | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've always used the alias
gm="git checkout master"
to switch to my master branch.I'm now moving to using
main
instead of master, but wantgm
to work on old and new projects as it used to. This tiny bash function does what I need.