Git / gerrit, push remote rejected no changes made
Asked Answered
M

11

45

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.

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.

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)
Macedonian answered 21/12, 2012 at 14:49 Comment(5)
What push command are you running, and what branch are you on locally?Arielariela
I'm on master locally, and I'm running git push origin master:refs/for/master and origin is set up with valid fetch and push URLs.Macedonian
Given that you're using refs/for/... rather than refs/heads/... syntax, are you using Gerrit? If so, that would be highly relevant to your question and should be mentioned.Arielariela
Ah yes, I am using gerrit. I'll update the question.Macedonian
Usually I do git push origin HEAD:refs/for/master when pushing to gerrit.Doviedow
M
52

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.

 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.

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.

Macedonian answered 9/1, 2013 at 16:1 Comment(1)
We had a problem with this today. The problem was that we had in gerrit: Change1 (merged) -- Change2 (unmerged) - Change3 (unmerged) We wanted to apply publish a new patch set to Change3 but it was denied. Message: ! [remote rejected] master -> refs/for/master (no changes made) After scratching our heads we found out we had rebased locally and that Change2 had also received a new commit hash but it had no new changes. We solved it by rebasing interactive locally again and reworded Change2 by adding a character at the end of the commit message. After that it was fine to publish.Trawl
B
10

Please refer to the official documentation on this issue here:

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, wrongfully amended my commit and pushed again. That is where I got the error.

My fix:

  1. If you just want to quickly get around this issue, do git commit --amend, remove the existing change-Id, assuming you have the git hooks set up, you can finish the commit and a new change-Id should be assigned to you.
  2. Go into gerrit and search for your existing change-Id, figure out what is going on, and fix accordingly. (recommended)
Beano answered 15/3, 2017 at 19:0 Comment(0)
S
3

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.

Shawm answered 15/1, 2014 at 2:38 Comment(2)
I had to do a "git commit --amend" with no changes, and this seemed to fix my problem.Surd
@Stuart, thanks! This helped me as well! For a quick approach, I made an interactive rebase over master (git rebase -i master). There, after each pick (...) line I have added x git commit --amend --no-edit (add also --no-verify if you have costly hooks). This executed smoothly and the problem with pushing for review disappeared!Filthy
A
2

i had the same issue. Just changed the commit message and pushed the code. It was successful.

Appledorf answered 28/8, 2018 at 17:32 Comment(2)
I have multiple commits and I want to push all of them, how can I do so?Mime
doesnt work at allRapport
F
1

It sounds like you are doing everything correctly as far as verifying you have made a change that Gerrit should pick up.

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:

git push origin HEAD:refs/for/master

HEAD is a shortcut that represents your current commit in git.

Floyfloyd answered 21/12, 2012 at 20:51 Comment(3)
Same error with that shortcut. Does HEAD refer to current change in current branch, or only current change in master branch?Macedonian
HEAD refers to your current change, period. The branch you are on doesn't matter. If pushing with HEAD doesn't help, I suspect your amend didn't change the commit. Try updating/changing the commit message when you amend and then pushing again.Floyfloyd
Thanks for your help Brad, found out I'd been using git incorrectly.Macedonian
C
1

I got this error when I pushed with a

git commit -m  "updated message"

and forgot the to include --amend

git commit --amend -m  "updated message"
Corkboard answered 6/10, 2021 at 15:56 Comment(0)
F
0

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.

Francyne answered 25/4, 2014 at 9:30 Comment(0)
V
0

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.

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.

Veterinary answered 25/11, 2014 at 20:17 Comment(0)
E
0

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.

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.

Extortion answered 16/8, 2016 at 10:19 Comment(0)
F
0

As others has pointed out that it is due to and abended review request. Same change id has been assigned to your commit.

My issue got resolved when I amended the commit git commit --amend and then removed the change id. After saving the a new change it was assingned to my commit and I was able to create the gerrit review.

Below comment is from one of the google groups

"If you amend the change and put a new Change-id it will work. I think this makes sense since the abandoned change is still around in Gerrit, so it has no other chance than requiring a new change-id otherwise it couldn't distinguish between the old abandoned change and the new one meant for the master branch."

Fordo answered 28/6, 2022 at 20:27 Comment(0)
C
-2

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...

Californium answered 20/11, 2019 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.