diff --git a/bin/git-checkout-default-branch b/bin/git-checkout-default-branch new file mode 100755 index 0000000..5011f73 --- /dev/null +++ b/bin/git-checkout-default-branch @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Checkout default branch +# This assumes that either `master` or `main` is the default + +if git show-ref --quiet refs/heads/master; then + git checkout master +elif git show-ref --quiet refs/heads/main; then + git checkout main +else + echo "Neither 'master' nor 'main' branch exists." +fi diff --git a/git/git-alii.zsh b/git/git-alii.zsh index bd7e381..4dd1567 100644 --- a/git/git-alii.zsh +++ b/git/git-alii.zsh @@ -16,7 +16,7 @@ alias gcl="git clone" alias gcm="git commit -m" alias gco="git checkout" alias gcob="git checkout -b" -alias gcom="git checkout master" +alias gcom="git-checkout-default-branch" alias gcon="git checkout main" alias gcp="git cherry-pick" alias gcpa="git cherry-pick --abort"