首页 > 其他 > 详细

Git命令自定义别名

时间:2014-08-25 11:46:34      阅读:199      评论:0      收藏:0      [点我收藏+]

别名用来帮助你定义自己的git命令。比如你可以定义 git a 来运行 git add --all

要添加一个别名, 一种方法是打开 ~/.gitconfig 文件并添加如下内容:

[alias]
  co = checkout
  cm = commit
  p = push
  # Show verbose output about tags, branches or remotes
  tags = tag -l
  branches = branch -a
  remotes = remote -v

...或者在命令行里键入:

$ git config --global alias.new_alias git_function

例如:

$ git config --global alias.cm commit

指向多个命令的别名可以用引号来定义:

$ git config --global alias.ac ‘add -A . && commit‘

下面列出了一些有用的别名:

别名 Alias命令 Command如何设置 What to Type
git cm git commit git config --global alias.cm commit
git co git checkout git config --global alias.co checkout
git ac git add . -A git commit git config --global alias.ac ‘!git add -A && git commit‘
git st git status -sb git config --global alias.st ‘status -sb‘
git tags git tag -l git config --global alias.tags ‘tag -l‘
git branches git branch -a git config --global alias.branches ‘branch -a‘
git remotes git remote -v git config --global alias.remotes ‘remote -v‘
git lg git log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit -- git config --global alias.lg "log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit --"


来源:bubuko.com,布布扣 tonyxue

Git命令自定义别名

原文:http://www.cnblogs.com/taylorblog/p/3934518.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!