git branch --show-current was introduced in git 2.22.
You can see in 2.21 branch docs that there's no --show-current arg.
The following method works with up-to-date and older git versions:
git rev-parse --abbrev-ref HEAD.
Yet another alternative to get the current branch, that looks more robust but is multiple lines long, can be found in oh-my-zsh git.zsh script. (for example's sake, replace __git_prompt_git with git).
I hope I'm not being oblivious to past decisions made about this line, maybe --show-current was used deliberately and I'm just creating extra work.
This suggested change is what was used before. I migrated because after git init the git rev-parse fails or does something weird. I don’t remember exactly.
git branch --show-current
was introduced in git 2.22.You can see in 2.21
branch
docs that there's no--show-current
arg.The following method works with up-to-date and older git versions:
git rev-parse --abbrev-ref HEAD
.Yet another alternative to get the current branch, that looks more robust but is multiple lines long, can be found in oh-my-zsh git.zsh script. (for example's sake, replace
__git_prompt_git
withgit
).I hope I'm not being oblivious to past decisions made about this line, maybe
--show-current
was used deliberately and I'm just creating extra work.Thanks for git-fuzzy! I use it everywhere I go.
Gilad