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

5

11

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?

Coup answered 22/5, 2014 at 13:19 Comment(4)
What does the alias git review stand for?Swung
@TimCastelijns: github.com/openstack-infra/git-reviewPina
Easiest fix would be to make a super minor edit (edit a comment or something), amend the commit and retry with the correct commandSwung
using amend will show only those changes on review board which was "amended"Misogyny
M
5

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.

Misogyny answered 22/5, 2014 at 13:41 Comment(2)
Won't this mess with Gerrit's internal database?Coup
I think the problem is that on remote branch there is already a commit with that changeId you are trying to push to review branch as well. No it wont since this commit with that changeId has not reviewed yet - so no any entry for this in Gerrit database.Misogyny
D
8

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
Decima answered 26/12, 2014 at 11:12 Comment(1)
For me this happened when I pushed the same patch for master and then for a feature brach. The problem was that the two patches had the same change-id so the second push was rejected. After the commit --amend it worked fine.Pigheaded
M
5

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.

Misogyny answered 22/5, 2014 at 13:41 Comment(2)
Won't this mess with Gerrit's internal database?Coup
I think the problem is that on remote branch there is already a commit with that changeId you are trying to push to review branch as well. No it wont since this commit with that changeId has not reviewed yet - so no any entry for this in Gerrit database.Misogyny
I
0

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.

Incalescent answered 6/12, 2015 at 13:39 Comment(0)
M
0

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.

Mercorr answered 12/2, 2019 at 2:38 Comment(0)
M
-2

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
Midpoint answered 19/4, 2016 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.