问题
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://lytee@gerrit.mycompany.net:29418/myrepo
Push URL: ssh://lytee@gerrit.mycompany.net: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)
回答1:
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.
回答2:
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:
- 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)
回答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.
回答4:
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.
回答5:
i had the same issue. Just changed the commit message and pushed the code. It was successful.
回答6:
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.
回答7:
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
.
回答8:
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.
回答9:
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...
来源:https://stackoverflow.com/questions/13992229/git-gerrit-push-remote-rejected-no-changes-made