Git 原来 git 的别名还可以这样用呀

zlfera · 2014年01月17日 · 最后由 gonglexin 回复于 2014年01月19日 · 4700 次阅读

每天 git push zain master 时感觉字太多了,想把它改短一点就想到 git 的 alias,于是 alias.pz 'push zain master'。居然成功,以前没想到它可以这样用,不知道大家是怎么搞的,还是我孤陋寡闻。

mer = merge co = checkout ca = commit -a st = status br = branch bra = branch -a pso = push origin plo = pull origin ft = fetch ftp = fetch -p origin logger = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --

custom command allowed...

关于 alias,用 bash 的 alias 也可以做到 ps:知道 git bash-completion 吗?如果不知道的话,你会发现他很爽

我比较常用的几个 git alias:

gst  #=> git status
gll  #=> git log --pretty="format:%C(yellow)%h%C(green)%d %C(white)%s %C(cyan)%an, %ar %Creset --graph"
glla #=> gll --all
gb   #=> git branch
gba  #=> git branch --all
gp   #=> git push
gl   #=> git pull
glr  #=> git pull --rebase
gco  #=> git checkout
gsu  #=> git stash -u
gsp  #=> git stash pop
grm  #=> git rebase master
grc  #=> git rebase --continue
gcp  #=> git cherry-pick
gcm  #=> git commit --message

我一般都避免使用 alias

需要 登录 后方可回复, 如果你还没有账号请 注册新账号