避免拉取请求中无用的策略错误?

Avoid useless policy errors on a pull request?

我正在尝试测试拉取请求。我执行了一个新的克隆:

$ git clone https://github.com/weidai11/cryptopp.git cryptopp-ds
$ cd cryptopp-ds

然后我发出以下命令来拉 pr:

$ git checkout -b droark-master master
$ git pull https://github.com/droark/cryptopp.git master

它导致完全不相关错误完全没有依据 停止此工作流程:

From https://github.com/droark/cryptopp
 * branch            master     -> FETCH_HEAD

*** 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 'cryptopp@qotom.(none)')

git pull --force https://github.com/droark/cryptopp.git master 产生相同的错误。

我对作者 Git 试图强加给我的这些无用、无关的政策决定不感兴趣。没有与此测试帐户关联的电子邮件地址。我只是想要这些文件,以便我可以测试更改。

我应该如何提取请求以便测试更改?

您无法执行 git pull 因为您没有设置 your Git identity.

git pullgit fetch && git merge.

的快捷方式

git 拉取文档:

More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge.

当 Git 执行 merge 命令时,它会创建提交。所以如果没有 credentials.

这是不可能的

如果本地和远程分支发生分歧,git pull 将执行合并并提交。每个提交都需要一个作者,这显然不是你所指的愚蠢政策。

根据文档,git pull 有一个参数 --no-commit,所以我希望你能对你有用,即:

git pull --no-commit https://github.com/droark/cryptopp.git master

不幸的是,从 Git v1.9 开始,情况并非如此。我无法用更新的版本测试这个,我建议你试试。

另一件没有用的事情是像这样使用获取+合并:

git remote add droark https://github.com/droark/cryptopp.git
git fetch droark
git merge --no-commit droark/master

同样的结果,它需要用户名和电子邮件配置。它似乎过早地进行了配置检查,因为在这种情况下显然不应该进行任何提交。您可能需要为此提交错误。

目前看来,您只需要接受并设置用户名 + 电子邮件即可。您不必像错误消息所建议的那样将其设置为全局设置,您可以简单地删除 --global 标志。

更新

另一种无需提交即可获取更改的方法是挑选要合并的提交范围:

git remote add droark https://github.com/droark/cryptopp.git
git fetch droark
git cherry-pick --no-commit ..droark/master

这应该有效,并且具有相同的结果。