#.gitconfig
[alias]
# use 'git h <command>' for help, use 'git la' to list aliases =====
h = help #... <git-command-in-question>
la = "!grep '\t=' ~/.gitconfig | less"
“\t=”部分匹配< kbd >标签< / kbd > < kbd > = < / kbd >。
为了更好地了解我所拥有的别名,并且因为我使用bash控制台,所以我用终端颜色对输出进行了着色:
所有'='都用红色打印
所有的“#”都以绿色打印
高级版:(彩色)
la = "!grep '\t=' ~/.gitconfig | sed -e 's/=/^[[0;31m=^[[0m/g' | sed -e 's/#.*/^[[0;32m&^[[0m/g' | less -R"
# choose =====
a = add #...
aa = add .
ai = add -i
# unchoose =====
rm = rm -r #... unversion and delete
rmc = rm -r --cached #... unversion, but leave in working copy
# do =====
c = commit -m #...
fc = commit -am "fastcommit"
ca = commit -am #...
mc = commit # think 'message-commit'
mca = commit -a
cam = commit --amend -C HEAD # update last commit
# undo =====
r = reset --hard HEAD
rv = revert HEAD
在我的linux或mac工作站中,进一步的别名也存在于.bashrc中,有点像:
#.bashrc
alias g="git"
alias gh="git h"
alias gla="git la"
function gc { git c "$*" } # this is handy, just type 'gc this is my commitmessage' at prompt
这样就不需要输入git help submodule,也不需要输入git h submodule,只需要输入gh submodule就可以获得帮助。只是一些字符,但你多久打一次?
$ alias gita="cat ~/.gitconfig .git/config 2>/dev/null | sed -n '/alias/,/\[/p' | grep -v '^\['"
$ gita
co = checkout
br = branch
ci = commit
st = status