2

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?

  • I'm looking for a better solution for this as well. Ideally you could use alias g="git " (with that trailing space) and then run gs and the s 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. – Keith Smiley Dec 9 '13 at 1:06
2

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"
  • 1
    I wonder why you can't this do in a file that isn't .gitconfig: ````` alias g="git " alias a="add" – Kevin Suttle Oct 3 '13 at 14:03
  • @KevinSuttle if this isn't in a .gitconfig, that means it is a shell alias. And shell alias works with a complete command, not the composition of two separate commands/parameters. alias gb or alias ga is fine (and can be defined in a .profile or .bashrc). – VonC Oct 3 '13 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.