git config文件总结及git alias配置

62 篇文章 0 订阅
36 篇文章 0 订阅

 

参考:

git config文件总结及git alias配置

https://www.cnblogs.com/mengff/p/5504549.html

 

1. 文件位置

mac

/etc/.gitconfig 系统级
~/.gitconifg 用户级(覆盖系统级)

windows

C:\Users\$user\.gitconfig

当前项目下

.git/.gitconfig(覆盖用户级)

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

复制代码

[user]
	name = xxx
	email = xxx@yyy.com
[core]
	editor = vim
[color]
	ui = auto
[alias]
	lm = log --no-merges --color --date=format:'%Y-%m-%d %H:%M:%S' --author='xxx' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
	lms = log --no-merges --color --stat --date=format:'%Y-%m-%d %H:%M:%S' --author='xxx' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
	ls = log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
	lss = log --no-merges --color --stat --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
	ll = log --no-merges --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cgreen(%cd) %h -%C(yellow)%d%Cblue %s %C(bold blue)<%an>%Creset %Cred%ae%Creset' --abbrev-commit
	llm = log --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cgreen(%cd) %h -%C(yellow)%d%Cblue %s %C(bold blue)<%an>%Creset %Cred%ae%Creset' --abbrev-commit
	llss = log --no-merges --color --stat --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset %Cred%ae%Creset' --abbrev-commit
	lly = log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset %Cyellow%ae%Creset' --abbrev-commit
	lll = log  --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cgreen(%cd) %Cred%h%Creset -%C(yellow)%d%Cblue %s %C(bold blue)<%an>%Creset %Cred%ae%Creset'
	st = status
	co = checkout
	br = branch
	ci = commit
[gui]
	editor = vim
[credential]
	helper = store
[init]
	templatedir = /home/xxx/.git_template
[cola]
	spellcheck = false

 



平时在使用 svn 时习惯使用 ci(commit)、co(checkout) 、st(status)等简洁的命令,但是在 Git 中没有提供这些简洁的命令,不过 Git 提供了别名机制,使用别名机制可将复杂的命令变的简洁。

git config --global alias.ci commit

git config --global alias.co checkout

git config --global alias.st status

git config --global alias.br branch

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"

 

 

 

参考:http://blog.csdn.net/joe_007/article/details/7276195
   http://blog.csdn.net/shrimpcolo/article/details/49302619

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值