tags:

views:

222

answers:

2

Github has the following recommendation for ~/.gitconfig

[alias]             # Is this [-] only a comment in .gitconfig?
gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate  
gl = git pull
gp = git push
gst = git status

The above commands worked in my old Git. However, they do not work now for some unknown reason.

The problem seems not to be in the commands. It is perhaps in some Git's file which controls which file affects aliases.

How can you get the aliases to work?

+5  A: 

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

$ git st

If you want to be able to do:

$ gst

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

Well, for aliases which are simply shorter versions of git commands (like st for status), you do not need to add the git prefix to it. Additionally, if you want to execute a shell command rather than a git sub-command, you must prefix the alias definition with an exclamation point, as specified in git-config(1). My alias section 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 so on.

haxney
The `git new` gives me http://files.getdropbox.com/u/175564/Picture%201.png
Masi
See http://stackoverflow.com/questions/964876/head-and-orighead-in-gitI should probably change it, but I don't actually ever use "git new", so I never noticed.
haxney
+4  A: 

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

In other terms, you would need to type, like illustrated here, the following 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’
VonC