I used to keep my git aliases in a file outside of my .gitconfig
file, in the normal format of:
alias gb="git branch --verbose"
which worked great. But, after looking around at others' dotfiles, I thought I'd try putting them in my .gitconfig
and see how that felt. But, I got a little hung up on how or if I can use the actual word git
inside of the .gitconfig
aliases.
Example:
.gitconfig
[alias]
g = git
a = add
b = 'branch --verbose'
This doesn't work (with or without the !
in front of the g
).
❯ gb
zsh: correct 'gb' to 'bg' [nyae]? n
zsh: command not found: gb
Now, I can put this alias in .zshrc, but it doesn't work that way either. I get the same output as above, even after reloading my shell.
alias g='git'
Are people manually typing out git a
, etc. every time?
alias g="git "
(with that trailing space) and then rungs
and thes
would be interpreted by the git aliases. Unfortunately aliases with trailing whitespace mean search other aliases for any other passed characters/arguments. Trying to find a way around this.