【问题标题】:How to apply a patch using git without configuration如何在没有配置的情况下使用 git 应用补丁
【发布时间】:2014-11-18 03:28:55
【问题描述】:

我写了一些指令,也使用 git 来应用一些补丁。 这些说明旨在放入控制台并使用它完成。 像这样:

git am bar.patch
git am foo.patch

但 git 现在正在询问用户名/电子邮件:

*** 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 'root@user-VirtualBox.(none)')
You need to set your committer info first

这似乎不需要,因为只有补丁的作者出现在 git 日志中,而不是应用它们的人。有没有办法忽略配置?

编辑:错别字

【问题讨论】:

  • 所有提交都有作者和提交者,这是没有办法的。只配置一次用户名/电子邮件并完成它有什么问题?
  • 问题是人们复制&粘贴命令并没有看到git无法应用补丁(因为git没有配置)。

标签: git configuration patch


【解决方案1】:

见“Difference between author and committer in Git?

当您应用补丁时,您就是提交者。所以 Git 需要知道“你”是谁。

关于git am,如果您希望与这些补丁创建的提交相关联的日期与所述补丁中记录的日期相同,我建议您考虑使用--committer-date-is-author-date

【讨论】:

  • 补丁被应用到本地存储库并最终被丢弃。我尝试使用 git am --author "New Author Name " foo.patch,但 git 不接受这个。也许一个非 git 补丁是解决方案。
【解决方案2】:

Git 检查GIT_COMMITTER_NAMEGIT_COMMITTER_EMAILEMAIL 环境变量。这有效:

EMAIL=root@localhost git am foo.patch

【讨论】:

    猜你喜欢
    • 2011-03-26
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多