二、基本面
git的alias是通过配置文件进行定制的,这个配置文件能做的事情还有很多,远远超过这篇文档的主题。
git的全局配置文件一般叫做.gitconfig,当前仓库的配置文件是.git目录下的config文件。很明显,这俩配置文件的作用范围是不同的。
三、使用git alias
首先要修改配置文件
3.1 linux
我用的是ubuntu 12.04 LTS版本,其它的发行版可能会略有区别.
第一步 用你最喜欢的编辑器打开 ~/.gitconfig
第二步 再配置文件中加入alias块,内容如下,根据你的偏好进行修改
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
第三步 试试管用吗
3.2 windows
windows系统的配置文件一般是位于git安装目录下的etcgitconfig文件。
备注
1 2 3 4 5 6 7 8 9 10 11 12 |
|
2.配置用户名和邮箱
全局
$ git config --global user.name ygtzz
$ git config --global user.email ygtzz@126.com
局部(当前项目)
$ git config user.name ygtzz
$ git config user.email ygtzz@126.com
3.快速打开gitconfig
git config [--global] --edit
4.修改编辑器
$ git config --global core.editor emacs
5.查看gitconfig内容
$ git config --list
git alias配置
[alias]
st = status -sb
co = checkout
br = branch
mg = merge
ci = commit
ds = diff --staged
dt = difftool
mt = mergetool
last = log -1 HEAD
latest = for-each-ref --sort=-committerdate --format="%(committername)@%(refname:short) [%(committerdate:short)] %(contents)"
ls = log --pretty=format:"%C(yellow)%h %C(blue)%ad %C(red)%d %C(reset)%s %C(green)[%cn]" --decorate --date=short
hist = log --pretty=format:"%C(yellow)%h %C(red)%d %C(reset)%s %C(green)[%an] %C(blue)%ad" --topo-order --graph --date=short
type = cat-file -t
dump = cat-file -p
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[core]
autocrlf = true
[push]
default = simple
git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
user.name=zyc
user.email=zyc@163.com
alias.co=checkout
alias.st=status
alias.df=diff
alias.ss=status -s
alias.cm=commit -m
alias.br=branch
alias.bm=branch -m
alias.bd=branch -D
alias.cb=checkout -b
alias.ll=log --graph --pretty=format:'%Cred%h%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative
alias.lg=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative
alias.alg=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative --all
alias.ls=log --stat
alias.plo=pull origin
alias.pho=push origin