.dotfiles/.config/fish/functions/__git.default_branch.fish
2024-10-21 20:46:27 +03:00

11 lines
467 B
Fish

function __git.default_branch -d "Use init.defaultBranch if it's set and exists, otherwise use main if it exists. Falls back to master"
command git rev-parse --git-dir &>/dev/null; or return
if set -l default_branch (command git config --get init.defaultBranch)
and command git show-ref -q --verify refs/heads/{$default_branch}
echo $default_branch
else if command git show-ref -q --verify refs/heads/main
echo main
else
echo master
end
end