Subject: Re: default aliases (ci, di, st, co)

From: Jakub Narebski <[email-masked]>
Date: Wed, 08 Jul 2009 17:13:57 -0700 (PDT)

Ondrej Certik <[email-masked]> writes:

> coming to git from mercurial and svn, here is the alias part of my
> .gitconfig:
> 
> [alias]
>     ci = commit
>     di = diff --color-words
>     st = status
>     co = checkout
> 
> 
> And all is fine until I share commands to checkout my branch (for
> example) with other people, then basically I have to write those
> commands in full (e.g. commit, checkout, ...), since I cannot assume
> they have their .gitconfig setup the same way I do. Especially for
> people who are new to git.

If you have admin rights on the machine, you can do that either using
system git config file (git config --system) i.e. $(prefix)/etc/gitconfig
or rather $(sysconfdir)/gitconfig, or by providing 'config' template
(copied as default repository config on init) in some place like
/usr/share/git-core/templates/config .

> 
> What is the view on this in the git community? Do most of you write
> 
> git checkout -b branch ...
> 
> (possibly with TAB completion) or do most of you write
> 
> git co -b branch ...
> 
> (like I do all the time, except when sharing my commands with other
> people)?

I use tab completion for commands like "git commit", "git show", "git
checkout" etc. (most important part is branch completion, not command
completion IMVHO).

But I do have few aliases:

[alias]
        cat  =    cat-file -p
        less = -p cat-file -p
        alias = config --get-regexp ^alias\\.
        lg = log --pretty=oneline --abbrev-commit
        one = show -s --pretty='format:%h (%s)'
        llog = log --date=local
        who = "!sh -c 'git log -1 --pretty=\"format:%an <%ae>\" --author=\"$1\"' -"
        lb = for-each-ref --format='%(refname)' \
             --sort=-authordate --count=8 refs/heads/
        rllog = log -g --date=relative
        rlg   = reflog show @{now}
        sed = !git ls-files --stage | grep ^100 | awk '{print $4}' | xargs sed

I use most often "git one" aliase (hmmm... I have just noticed that
"git lg" alias is now superfluous with new '--oneline' option).

> Could in principle those aliases be even made default by git? Or is
> this not a good idea.

The "default/built-in aliases" idea was discussed on git mailing list
a few times in the past...

-- 
Jakub Narebski
Poland
ShadeHawk on #git