背景
使用别名简化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”
这里只展示了部分常用别名 也可添加自己习惯的别名方便使用