设置别名git config
$ git config --global alias.ci commit
# git ci 代替git commit
$ git config --global alias.unstage "reset HEAD --"
# $ git unstage fileA
# $ git reset HEAD -- fileA
$ git config --global alias.last "log -1 HEAD"
# $ git last 方便查看最后一次提交信息
# git config --local alias.last "log -1 HEAD"
# git config --local alias.last 'log -1 HEAD'
# 书中给的例子是单引号, 但是总失败, 双引号成功 /(ㄒoㄒ)/~~
# 可能是windows cli 的问题, cmder?
# git bash 没问题 QAQ
$ git config --global alias.visual "!gitk"
# 外部命令用! 开头, 写一些与 Git 仓库协作的工具的话会用到
# git config --local alias.ls1 "!ls"
# 配置文件位置
Config file location
--global use global config file
--system use system config file
--local use repository config file
# local 的配置文件在, 本地仓库/.git/config
--worktree use per-worktree config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object
$ 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"
$ git lg # 效果如下图
删除别名 栈溢出问答
# 姿势1 --unset
$ git config --global --unset alias.last
# 姿势2 修改配置文件去吧