1. 编辑文件 ~/.bashrc
vim ~/.bashrc
最后一行加入alias g='git'
(等号两边不要有空格)
source ~/.bashrc
2. 编辑文件 ~/.gitconfig
vim ~/.gitconfig
加入以下内容(alias
后面配置的是别名)
[alias]
a = add .
cm = commit -m
plr = pull --rebase
ps = push
cs = checkout staging
fos = fetch origin staging
rs = rebase staging
fod = fetch origin dev
rd = rebase dev
cd = checkout dev
b = branch
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lga = log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
总结:
g a
= git add .
g cm
= git commit -m
g plr
= git pull --rebase
...