Git / gerrit,推送远程拒绝未做任何更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13992229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git / gerrit, push remote rejected no changes made
提问by edwardmlyte
Made changes to a commit, performed commit amend. Do a push and I get the error:
对提交进行了更改,执行了提交修改。推一下,我得到错误:
! [remote rejected] master -> refs/for/master (no changes made)
Checked the change ID in the commit message and its still a valid commit.
检查了提交消息中的更改 ID,它仍然是一个有效的提交。
I've tried changing a file, checking it shows up as an alteration and then added to staging area and done another commit amend. Try the push again and getting the same issue. No idea on this one.
我试过更改一个文件,检查它是否显示为更改,然后添加到暂存区并完成另一个提交修改。再次尝试推送并遇到相同的问题。不知道这个。
Edit: This is pushing to gerrit, not git directly.
编辑:这是在推动 gerrit,而不是直接 git。
I'm running:
我在跑:
git push origin master:refs/for/master
And the result of getting the details of origin are (with company details edited out):
获取原产地详细信息的结果是(删除了公司详细信息):
$ git remote show origin
* remote origin
Fetch URL: ssh://[email protected]:29418/myrepo
Push URL: ssh://[email protected]:29418/myrepo
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master rebases onto remote master
Local ref configured for 'git push':
master pushes to master (up to date)
回答by edwardmlyte
This issue is due to the actions I'd performed previously. I was trying to push
a new change, on top of a change which was still up for review, who's parent also was up for review.
这个问题是由于我之前执行的操作造成的。我正在尝试进行push
新的更改,除了仍在审核中的更改之外,谁的父母也需要审核。
Trunk ------ Parent A ----- Parent B ----- New change
(merged) (unmerged) (unmerged)
I had used cherry-pick
to obtain these two changes locally (Parent A and Parent B), and then a third cherry-pick
to get my change from a local branch before attempting to push
. That is what caused the issue, because my personal change was essentially trying to re-write history.
我曾经cherry-pick
在本地获取这两个更改(父 A 和父 B),然后cherry-pick
在尝试push
. 这就是导致问题的原因,因为我个人的改变本质上是试图重写历史。
The correct process would be to only pull
Parent B when at trunk. This automatically pulls up any commits between trunk and it (in this case just Parent A). Then cherry-pick
my new change on top of that and push
will work fine.
正确的过程是pull
在主干时只有父母 B。这会自动提取主干和它之间的任何提交(在这种情况下只是父 A)。然后cherry-pick
我在此基础上的新更改push
将正常工作。
回答by benjaminz
Please refer to the official documentation on this issue here:
请在此处参考有关此问题的官方文档:
https://gerrit-review.googlesource.com/Documentation/error-no-new-changes.html
https://gerrit-review.googlesource.com/Documentation/error-no-new-changes.html
I had the same issue, my issue was that I pushed the change, then abandoned that merge, then I made a few tweaks, wrongfullyamended my commit and pushed again. That is where I got the error.
我遇到了同样的问题,我的问题是我推送了更改,然后放弃了合并,然后我做了一些调整,错误地修改了我的提交并再次推送。那就是我得到错误的地方。
My fix:
我的修复:
- If you just want to quickly get around this issue, do
git commit --amend
, remove the existingchange-Id
, assuming you have the git hooks set up, you can finish the commit and a newchange-Id
should be assigned to you. - Go into gerrit and search for your existing
change-Id
, figure out what is going on, and fix accordingly. (recommended)
- 如果您只是想快速解决这个问题,请
git commit --amend
删除现有的change-Id
,假设您已经设置了 git 钩子,您可以完成提交,并且change-Id
应该为您分配一个新的。 - 进入 gerrit 并搜索您现有的
change-Id
,弄清楚发生了什么,并进行相应的修复。(受到推崇的)
回答by Matt Montag
If you are trying to update a set of reviews, each with their own change-id that you want to maintain (say, after a rebase where you swap the order of two commits), you might get rejected if some of the commits in the pile remain unchanged. You should force a new hash to be generated by rewording the commits, or something similar.
如果您尝试更新一组评论,每个评论都有自己想要维护的更改 ID(例如,在交换两次提交的顺序的 rebase 之后),如果某些提交中的某些提交,您可能会被拒绝桩保持不变。您应该通过重写提交或类似的内容来强制生成新的哈希值。
回答by schin chan
i had the same issue. Just changed the commit message and pushed the code. It was successful.
我遇到过同样的问题。刚刚更改了提交消息并推送了代码。它成功了。
回答by Brad
It sounds like you are doing everything correctly as far as verifying you have made a change that Gerrit should pick up.
听起来你做的一切都是正确的,只要验证你已经做出了 Gerrit 应该接受的更改。
git push origin master:refs/for/master
git push origin master:refs/for/master
Maybe this is the problem? If your changes aren't on your local version of the master branch, you aren't pushing your changes. Instead try:
也许这就是问题所在?如果您的更改不在 master 分支的本地版本上,则您不会推送您的更改。而是尝试:
git push origin HEAD:refs/for/master
git push origin HEAD:refs/for/master
HEAD
is a shortcut that represents your current commit in git.
HEAD
是表示您在 git 中当前提交的快捷方式。
回答by NullPointerException
I had the same issue. At the same time there was another commit not merged to master and was in gerrit review and rebased in gerrit. i.e. code pushed for review. rebased in gerrit and review pending to finish. Once the code was reviewed I was able to push without error.
我遇到过同样的问题。同时还有另一个提交没有合并到 master 并且正在 gerrit 中并在 gerrit 中重新定位。即代码推送。在 gerrit 中重新定位并等待完成。一旦代码被,我就能够毫无错误地推送。
回答by GabLeRoux
I had the same error message, but the changes I was trying to push were on top of different commits from the original Change set (did some magic tricks with git cherry-pick
and it seems gerrit did not like it). I abandoned my original change, then reopened it when I realized I could fix the issue, but failed to send to gerrit with git review
.
我有相同的错误消息,但我试图推送的更改是在原始更改集的不同提交之上(做了一些魔术git cherry-pick
,似乎 gerrit 不喜欢它)。我放弃了最初的更改,然后在意识到我可以解决问题时重新打开它,但未能将git review
.
At this point, my quick solution was to abandon the original change from gerrit website, and create a new change by removing the change-Id: sha1
last line from the commit message with git commit --amend
.
在这一点上,我的快速解决方案是放弃来自 gerrit 网站的原始更改,并通过删除change-Id: sha1
带有git commit --amend
.
回答by Androina Yang
With this error message Gerrit rejects to push a commit as a new patch set for a change, if the pushed commit is identical to the current patch set of this change.
如果推送的提交与此更改的当前补丁集相同,则 Gerrit 拒绝将提交作为更改的新补丁集推送,并显示此错误消息。
A pushed commit is considered to be identical to the current patch set if
推送提交被认为与当前补丁集相同,如果
- the files in the commit,
- the commit message,
- the author of the commit and
- the parents of the commit
- 提交中的文件,
- 提交消息,
- 提交的作者和
- 提交的父母
are all identical.
都是相同的。
回答by Raay Schneider
My simple solution is, to update project and then commit and push.
我的简单解决方案是,更新项目,然后提交和推送。
This help, becouse the master and your local branch are inconsistense. This can be, when you maybe rebase on gerrit...
这个帮助,因为master和你本地的分支不一致。这可能是,当您可能基于 gerrit 时...