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

时间:2016-02-28 13:38:31

标签: git git-pull

我试图测试拉取请求。我做了一个新的克隆:

$ 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试图逼迫我的这些无用的,无关紧要的政策决定不感兴趣。此测试帐户没有与之关联的电子邮件地址。我只是想要文件,所以我可以测试更改。

我究竟如何提取请求以便测试更改?

2 个答案:

答案 0 :(得分:2)

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

git pullgit fetch && git merge的快捷方式。

git pull docs:

  

更准确地说,git pull使用给定的参数运行git fetch并调用git merge将已检索的分支头合并到当前分支中。使用--rebase,它运行git rebase而不是git merge。

当Git执行merge命令时,它会创建提交。因此,如果没有凭据,这是不可能的。

答案 1 :(得分:2)

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

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

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

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

另一件不起作用的是使用fetch + merge这样:

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

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