背景
使用別名簡化git的各項命令 備忘
參考:https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
方法
1.單條增加
使用命令
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
直接使用上述命令可以添加git別名
git co 可以替代 git checkout
2.直接編輯配置文件 批量加入
使用命令
git clone --global --edit
打開git配置文件編輯 (該文件一般在~/.gitconfig 可以直接打開編輯)
添加如下alias
[alias]
st = status
co = checkout
cl = clone
br = branch
mg = merge
ci = commit
md = commit --amend
dt = difftool
mt = mergetool
保存退出 即可使用 “git st” 代替 “git status”
這裏只展示了部分常用別名 也可添加自己習慣的別名方便使用