git - Git 中两个或多个 User.Name 有什么用。

标签 git

我是 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 字段,其值分别为 antoanto aravinth。那么这里的两个 user.name 有什么意义呢?允许多个用户使用同一系统还是其他什么?由于我是新手,所以如果答案足够简单就好了。

提前致谢。

最佳答案

git config man page 中所述:

  • GIT_AUTHOR_NAMEGIT_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/

相关文章:

git - 使用 `curl` 通过双因素身份验证在 GitHub.com 上创建一个 repo

Git - 列出暂存期间所有更改的文件

git - Flutter无法切换 channel

git - 在使用 Hudson/Jenkins 等 CI 工具时,我如何通过 GitHub(或 GitHub 企业版)成功使用 Maven 发布插件

git - git:看起来不像分支的分支

git - 如何让 travis 克隆 git SSH URLs?

git - 如何在 git 中将 2 个分支从本地推送到远程仓库?

git - 如何通过 sneaker net(外部文件)将 Git 更改集从一个存储库导出到另一个存储库?

git - 如何将提交从主干移动到 Git 中的分支?

git-http-backend 导致通过 http 推送代码时出现问题