我是 Git 的新手,我已经开始使用免费在线 book 学习 Git .我几乎没有疑问要澄清:
我已经使用这个命令来设置我的 Git:
$ git config --global user.name "Anto"
后来我只用了这个命令:
$ git config user.name "anto aravinth"
(即没有 --global
选项)
现在,当我使用以下命令运行时:
$ git config --list
我得到的输出是:
user.name=Anto
user.email=anto.aravinth.cse@gmail.com
push.default=matching
color.status=auto
color.branch=auto
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
user.name=anto aravinth
在上面的命令中,我可以看到两个 user.name
字段,其值分别为 anto
和 anto aravinth
。那么这里的两个 user.name
有什么意义呢?允许多个用户使用同一系统还是其他什么?由于我是新手,所以如果答案足够简单就好了。
提前致谢。
最佳答案
如 git config
man page 中所述:
GIT_AUTHOR_NAME
和GIT_COMMITTER_NAME
等环境变量将覆盖本地配置(当前仓库中的配置)- 本地配置将覆盖全局配置(
$HOME/.gitconfig
中的配置,假设您已经定义了一个环境变量HOME
,知道它不是由Windows 上的默认设置) - 全局配置将覆盖系统配置(git 安装目录本身的配置)
注意 git config --list --local
可能有几个错误信息:
fatal: unable to read config file '.git/config': No such file or directory
(如果在 git repo 目录之外完成)
error: unknown option local
(如果使用 git1.7.1 或更低版本和在 git 存储库之外运行,如 git-dropbox ticket 所示。solution 将忽略错误消息:
DROPBOX_REPO=`git config --local dropbox.repo 2>/dev/null`
)
关于git - Git 中两个或多个 User.Name 有什么用。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8336850/