【问题标题】:Bypass "Tell me who you are" error in git绕过git中的“告诉我你是谁”错误
【发布时间】:2015-12-17 00:50:41
【问题描述】:

在尝试提交存储库时,我收到错误:

$ git commit

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got '[output redacted]')

显而易见的解决方案是在输出中运行 git config 选项,但我不想这样做。

相关计算机不属于特定人员,而是共享计算机。因此,每次提交都会是不同的用户。

如何绕过这一点并将作者设置为每次提交而不是全局?

【问题讨论】:

  • 如果您运行 git config 而不使用 --global 选项,您将仅为该特定克隆设置作者。
  • @approxiblue 如果多个人要添加到同一个克隆怎么办?
  • 为多个提交者提供一个克隆无论如何都是有问题的做法。你为什么要这么做?
  • 代码是作为一个团队工作的。有问题的计算机也属于团队,没有人明确表示,这意味着团队中的任何人都可以使用它。

标签: git git-commit git-config


【解决方案1】:

您可以使用--author 标志:

$ git commit --author="A U Thor <author@example.com>" 

【讨论】:

  • 我听说作者和提交者是不同的东西?
  • 当 config 是一个名字并且作者被更改时会发生这种情况:i.imgur.com/d933jHh.png
  • 为什么是图片?是的,作者和提交者是不同的。
  • 从 git 2.12.2 开始,如果未设置默认值,则会失败。
【解决方案2】:

另一种选择是使用-c 标志将配置参数传递给当前命令。

在你的情况下git -c user.email="your@email.com" -c user.name="Your Name" commit ...

-c 值会覆盖任何其他默认值(设置和取消设置参数)。请注意,所有-c 选项都需要位于命令名称commit 之前。

【讨论】:

  • 这适用于 be 但我必须使用语法 user.email="you@email.com"user.name="Your Name"(注意 = 符号)。
猜你喜欢
  • 2012-07-24
  • 2016-04-03
  • 1970-01-01
  • 1970-01-01
  • 2019-01-03
  • 1970-01-01
  • 2020-02-16
  • 2010-11-30
  • 1970-01-01
相关资源
最近更新 更多