2026-03-16

If you use the git plugin from Oh-My-Zsh, you’ve probably gotten used to the aliases gcm (checkout main) and gcd (checkout develop). Until you join a project with different default branches and see this:
gcm
error: pathspec 'master' did not match any file(s) known to git
gcd
error: pathspec 'develop' did not match any file(s) known to git
At the company I work for, we use a branching system different from the conventional one: the main branch is called staging (equivalent to main) and the development branch is called qa (equivalent to develop). This causes the Oh-My-Zsh aliases to not find the expected branches.
The Oh-My-Zsh git plugin uses two functions to resolve default branch names: git_main_branch and git_develop_branch. All aliases that depend on these branches (like gcm, gcd, grbm, gmd, among others) call these functions under the hood.
The solution is to override these functions to include your alternative branch names. I created a custom-git.zsh file in the Oh-My-Zsh custom directory:
# ~/.oh-my-zsh/custom/custom-git.zsh
With the following content:
# Overwrite Oh-My-Zsh git_main_branch function to also look up to default branch "staging"
git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,master,staging}; do
if command git show-ref -q --verify "$ref"; then
echo "${ref:t}"
return
fi
done
echo master
}
# Overwrite Oh-My-Zsh git_develop_branch function to also look up to default branch "qa"
git_develop_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{develop,dev,devel,development,qa}; do
if command git show-ref -q --verify "$ref"; then
echo "${ref:t}"
return
fi
done
echo develop
}
Oh-My-Zsh automatically loads any .zsh file inside ~/.oh-my-zsh/custom/, so you just need to reopen the terminal and the aliases will work again.
The functions iterate through a list of possible names (both local and remote branches) and return the first match. The order matters: if the repository has both main and qa, it will use main. If it only has qa, it will use qa.
This means the same setup works both in your personal projects (which use main/develop) and in company projects (which use qa/staging), without needing to change anything.