Gerrit: ! [remote rejected] HEAD -> refs/publish/master (no new changes)

冷暖自知 提交于 2021-02-07 11:45:08

问题


I made some changes, committed them and pushed the branch to Gerrit (git push gerrit). Now my changes don't appear in Gerrit and I assume this is because I pushed the changes manually instead of using git review. When I run git review now, Im getting this error:

remote: Processing changes: refs: 1, done    
To ssh://user@gerrit-host:29418/Project
! [remote rejected] HEAD -> refs/publish/master (no new changes)
error: failed to push some refs to 'ssh://user@gerrit-host:29418/Project'

How can I tell Gerrit that my changeset needs to be reviewed?


回答1:


I think the problem is that the commit already in remote branch. That is why no new changes on push. First try to remove the commit from remote branch, and then push the commit to review branch.




回答2:


you can remove that commit from remote branch or you can do this

git commit --amend

this will create a new patch

git push gerrit HEAD:refs/for/your_branch



回答3:


I've found that git review will not submit a branch with no changes. It's basically saying: "since there are no changes in your commit there's no reason to submit... so I won't". Unlike your situation, this has happened to me when there was an error in the previous push.

What I've done in these cases is simply add a minor change (such as adding a blank line) so that gerrit see things as different and then it works.

Another thing you could do (depending on the process your organization uses) is to remove the Change-Id from your change log (using git commit --amend) and then run git review, thus creating a new review set, essentially staring over as far as Gerrit is concerned.




回答4:


git commit --amend can't resolve several commits, only can push last one to gerrit.

Another resolution is to checkout and use cherry-pick commitid1 commitid2 commitid3, then push.




回答5:


To avoid this error

! [remote rejected] HEAD -> refs/for/develop (no new changes)

Just follow these steps

git commit --amend # this will create a new patch
git push gerrit HEAD:refs/for/your_branch


来源:https://stackoverflow.com/questions/23808032/gerrit-remote-rejected-head-refs-publish-master-no-new-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!