已经配置的别名

$ git config --global alias.st status
$ git config --global alias.co checkout
$ git config --global alias.ci commit
$ 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"

 

gitconfig部分文本

[alias]
    st = status
    co = checkout
    ci = commit
    br = branch
    lga = log --graph --decorate --oneline --simplify-by-decoration --all
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

 

别名生效的位置

  • ./etc/gitconfig 文件:包含了适用于系统所有用户和所有库的值。如果你传递参数选项’–system’ 给 git config,它将明确的读和写这个文件。
  • ~/.gitconfig 文件 :具体到你的用户。你可以通过传递 –global 选项使 Git 读或写这个特定的文件。
  • 位于 git 目录的 config 文件 (也就是 .git/config) :无论你当前在用的库是什么,特定指向该单一的库。每个级别重写前一个级别的值。因此,在.git/config中的值覆盖了在/etc/gitconfig中的同一个值。

 

在 Windows 系统上,Git 会找寻用户主目录下的 .gitconfig 文件。主目录即 $HOME 变量指定的目录,一般都是 C:\Users{UserName} 。此外,Git 还会尝试找寻 /mingw64/etc/gitconfig 文件,只不过看当初 Git 装在什么目录,就以此作为根目录来定位。 比如我的 git 安装目录是 C:\Program Files\Git, 那么相应的文件位置是C:\Program Files\Git\mingw64\etc 。

因此在配置别名的时候,如果指定 –system ,将会对所有的用户生效。
指定 –global 的时候,会对当前用户生效。 没有指定 –system 或者 –global 的时候,只在当前仓库生效

相关文章:

  • 2021-11-10
  • 2021-11-15
  • 2021-09-05
  • 2021-08-20
  • 2022-03-02
  • 2022-12-23
  • 2021-06-19
  • 2021-12-31
猜你喜欢
  • 2022-01-29
  • 2021-11-21
  • 2021-11-02
  • 2022-02-05
  • 2021-07-29
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案