What's the rule on using the word "git" as an alias?

What's the rule on using the word "git" as an alias?

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?

答案1

Are people manually typing out git a?

Yes.

Or you can define a shell alias (in addition of your git alias)

git alias b='branch --verbose'
alias gb="git b"

相关内容