[ACCEPTED]-How to get aliases working in .gitconfig?-alias

Accepted answer
Score: 19

The first thing to be aware of is that the 14 git aliases only apply when you are calling 13 git, so an alias of st = status will take effect when 12 you run:

$ git st

If you want to be able to do:

$ gst

To 11 run git status you would need to set up an alias for 10 bash (or whatever shell you use).

Well, for 9 aliases which are simply shorter versions 8 of git commands (like st for status), you do not 7 need to add the git prefix to it. Additionally, if 6 you want to execute a shell command rather 5 than a git sub-command, you must prefix 4 the alias definition with an exclamation 3 point, as specified in git-config(1). My alias section 2 of my ~/.gitconfig looks like this:

[alias]
    st = status
    ci = commit -s
    br = branch
    co = checkout
    vis = !gitk --all &

And then I can run:

$ git st # Runs "git status"
$ git ci # Runs "git commit -s"
$ git vis # runs "gitk --all &"

And 1 so on.

Score: 9

I believe what GitHub is referring to is 3 system aliases, not '.gitconfig' aliases.

In other terms, you 2 would need to type, like illustrated here, the following 1 Unix command to make those 'aliases' work:

alias g=’git’
alias gb=’git branch’
alias gba=’git branch -a’
alias gc=’git commit -v’
alias gca=’git commit -v -a’
alias gd=’git diff | mate’
alias gl=’git pull’
alias gp=’git push’
Score: 0

In my case, i navigated to .zsh folder and 1 cloned this repo as git clone https://github.com/mdumitru/git-aliases.git , then source ~/.zshrc and is worked.

More Related questions