53

i am having problems pushing my changes from my local master to remote master because of this error:

remote: Processing changes: refs: 1, done
To ssh://xxxxx@gerrit.dev.xxxxx.net:29418/xxxxxx
 ! [remote rejected] HEAD -> refs/for/master (change 14823 closed)
error: failed to push some refs to 'ssh://xxxxx@gerrit.dev.xxxxx.net:29418/xxxxxx'

any idea how i can fix this issue?

git status says my branch is ahead of origin/master by 5 commits.

ecatmur
  • 152,476
  • 27
  • 293
  • 366
Jono
  • 17,341
  • 48
  • 135
  • 217

19 Answers19

53

I got the same message. And it was because I have managed to get the same Change-Id for two commits. Maybe due to some cherry-picking or similar between my local branches. Solved by removing the Change-Id from the commit message, a new Id then was added by the commit hook.

Johan
  • 531
  • 4
  • 2
  • Just did the same thing. Cut and pasted the wrong Change-Id, then tried to push that. – Kaz Nov 20 '14 at 20:56
  • 1
    My problem came from a cherry-pick that had to be amended on a repo using gerrit. Removing Change-Id is the answer. – rickfoosusa Apr 28 '15 at 14:34
  • 2
    Will removing the change-id would create new gerrit change and produce the new review. I have a similar situation but don't want to loose my review comments and its history. – Krishna Oza Mar 21 '17 at 11:30
43

Your Commit Change ID is expired ie, Review 14823 is closed. you can't push to same.

Do this to fix issue:

  1. git commit --amend
  2. delete change id
  3. save and quit
  4. new change id will be added to the commit. it can be verified by git log.
  5. push again
alex
  • 479,566
  • 201
  • 878
  • 984
suprith
  • 479
  • 4
  • 7
  • Work for me .Thk you. – linjiejun Nov 08 '21 at 02:52
  • I have a pre-commit hook which runs test coverage. Is there any way to bypass that but run the commit-msg hook to generate change id? if I run --no-verify it bypasses both the hooks hence no change id is generated. – Sushmit Sagar Jun 16 '22 at 12:48
7

I found the following page which details exactly why you're unable to push your changes to the origin due to the change XXXXX closed error: https://git.eclipse.org/r/Documentation/error-change-closed.html

Cheers!

Sterling Bourne
  • 3,064
  • 23
  • 22
6

You have 5 commits.

All of them has a file called "Commit Message" (used by Gerrit).
One of these files has a bad "Change-Id" that was already accepted
and merged into master by Gerrit, and hence cannot be used again.

One fix is to merge all 5 commits into one,
and in the process of doing that,
delete the "Change-Id" in file "Commit Message".

In my case, I had 3 commits, so I did:
git rebase -i HEAD~3

There are other ways of merging multiple commits:
Squash my last X commits together using Git

Community
  • 1
  • 1
user77115
  • 5,517
  • 6
  • 37
  • 40
5

If you have been re-basing and picked commit(s) related to review(s) that has/have been closed (merged or abandoned) in the meantime, you can simply rebase again and instead of picking, drop the commit(s) related to the review. You should then be able to push again without any issue. I strongly disagree with suggestions to play/modify Change-Ids. Detailing git commands, this would give:

git fetch; git rebase origin/a_branch --interactive

Picking every commit... Fixing conflicts and then git add ...

git rebase --continue
git push origin HEAD:refs/for/refs/heads/a_branch

-> remote rejected... change ### closed

Then do the following:

git fetch; git rebase origin/a_branch --interactive

picking (pick) every commit except those related to change ### that should be dropped (drop). You should not have any conflict and get a rebase successfull right-away (conflicts were already solved in the previous rebase). Then:

git push origin HEAD:refs/for/refs/heads/a_branch
Phil
  • 390
  • 5
  • 5
1

The change 14823 closed message does not come from vanilla git. It indicates that whoever maintains that repository has an update or post-update hook that is evaluating your push and rejecting it due to local policy (I'm guessing you're adding additional commits to an issue that has already been marked as completed/closed). You'll need to find out what those policies are, and whether you need to somehow get the change re-opened so you can add commits to it, or if you need to create a new change request and (probably) rebase your work against it.

twalberg
  • 59,951
  • 11
  • 89
  • 84
  • what local policy could that be? all im doing is fetching latest code. doing some tweaks and pushing it. everytime it fails with the same message. Git is causing me soo much grief – Jono Aug 16 '12 at 09:03
  • It's not `git` causing the grief, though, as @ebneter points out in another answer, its gerrit, which has some policies built on top of `git`, implemented as hooks. You need to follow gerrits usage policies, and more specifically any additional ones imposed by the admin of that specific repository. – twalberg Aug 16 '12 at 13:37
1

git status says my branch is ahead of origin/master by 5 commits.

all im doing is fetching latest code. doing some tweaks and pushing it.

What are those 5 commits? Are they all yours?

Does change 14823 correspond to one of those 5 commits? What's its status in Gerrit?

Community
  • 1
  • 1
David Pursehouse
  • 933
  • 6
  • 14
  • I had a push failing since I had a commit in my log that was no longer in gerrit. try to fetch origin and reset --hard to remote HEAD, then apply your commit and push again. – Noich Jun 21 '16 at 12:20
1

in my case I had 2 commits, the first commit was mine but second one wasn't, so I fix it this way:

  1. find out which files were committed in change 14823
  2. find your oldest commit and do a soft reset to its parent. be aware, if you do a hard reset you may lose all your commits.
  3. try to commit your changes one more time but in this time without the files from change 14823

I hope it's helpful.

alex
  • 479,566
  • 201
  • 878
  • 984
Hazhir
  • 780
  • 1
  • 6
  • 18
1

I also faced this problem, Here is the solution

  1. do git pull --rebase
  2. try to upload it again

if you face any merge conflict, try to merge it manually and the do git rebase --continue

0

You're pushing to gerrit, which is a code review tool, as indicated by both the url (ssh://xxxxx@gerrit.dev.xxxxx.net:29418/xxxxxx) and the "HEAD -> refs/for/master" message. You need to consult with whoever maintains the repository you're trying to push to in order to figure out why the change is being rejected.

ebneter
  • 20,795
  • 9
  • 30
  • 30
0

Try this. git push --no-thin origin xxxxxx:refs/for/sprint/yyyyyy

keylan
  • 33
  • 1
  • 4
0

I and my senior work more than 1 hour to get solution, So I tried below, It works for me

  1. Backup all branches from .git/logs/refs/heads/{{branch}} folder and updated files in repo
  2. Removed Branches which cause error
  3. Create Branch "git branch '{{new branch name}}'"
  4. move back repo files to relevant folder
  5. git commit -m "{{commit message}}"
  6. git push origin HEAD:refs/for/master

Every thing should be fine and done nicely

0

I encounter this problem too, when I push my commit and the terminal says:

! [remote rejected] HEAD -> refs/for/android_ui.lnx.1.2.c1-dev (change 1692698 closed)

I go to review site to see the change corresponding 1692698, the commit message is: "Prompt USB tethering help when first time enable WiFi hostpot"

Then show the commit logs in terminal:

  • b49c0f91744cb6f863616976c4fb4157c7af4b8c The prompt is not correct when enable USB tethering with Wi-Fi connected.
  • eb47ef919064aff516ced4bbd9d8ade0ed34b107 Prompt USB tethering help when first time enable WiFi hostpot
  • 753668be1207baa514be1bbd985f3db2d6317608 Fix hotstop Notification bug.

The reason why push fail is that the current changID is the same with that of eb47ef919064aff516ced4bbd9d8ade0ed34b107 commit. so I backup current change and reset hard to 753668be1207baa514be1bbd985f3db2d6317608 and then apply the backup change, add, commit and push successively finally.

Hope this can solve your problem.

Saint
  • 1,492
  • 1
  • 11
  • 20
0

This can happen if there already exists a change on gerrit that either has been merged or even abandoned. If abandoned, which was my case, restore that change on gerrit and apply the new change on top of the restored change.

https://gerrit-review.googlesource.com/Documentation/error-change-closed.html

r11
  • 107
  • 1
  • 4
0

You have 5 commits.

Each commit has a "Commit Message" that may contain a "Change-Id:" string that identifies which Change Request that commit belongs to for Gerrit (see https://git.eclipse.org/r/Documentation/user-changeid.html)

In this case one (or more) of the Change Requests identified by the Change-Id strings is already merged or abandoned by Gerrit, and hence cannot be used again.

You need to modify the commit message for one (or more) of the commits before pushing them (see http://schacon.github.io/history.html), either removing them to create new Change Requests, or modifying them so that they identify the correct Gerrit Change Requests for each commit.

qneill
  • 1,643
  • 14
  • 18
0

Solution for EGit users:

  1. Click Amend button enter image description here


  1. Delete Change-Id from commit message area using backspace button (this will be something different from this screenshot)
  2. Click 'Add Change Id' buttonenter image description here

  3. Commit your changes & push.

burak
  • 3,839
  • 1
  • 15
  • 20
0

Issues can be several but if problem is that your change is on top of an outdated commit (for any reason, it might have been merged) you just need to:

Step 1: Find the commit before the commit you want to remove git log

Step 2: Checkout that commit git checkout

Step 3: Make a new branch using your current checkout commit git checkout -b

Step 4: Now you need to add the commit after the removed commit git cherry-pick

Now push your changes to gerrit, it should accept them.

See: https://www.clock.co.uk/insight/deleting-a-git-commit

nurieta
  • 1,615
  • 15
  • 6
0

If you have multi commits.And the closed commit is not the latest one.At this situation,you can not use --amend to modify the change-Id.Because the --amend can just modify the latest commit message.

At this situation,use git rebase origin/master -i and use reword rather than pick on the commit that you need to modify the change-Id.

When pop up the editor that request to edit the commit message.Just delete the change-Id line and save.This will create a new change-Id.

linjiejun
  • 1,468
  • 15
  • 22
  • 如果被close的commit不是最新的,--amend不能够解决。使用rebase交互模式中的`reword`子命令,来reword需要修复的commit。保存后弹出,需要进行重新编辑提交消息的时候,简单删除change-Id.保存,将会自动生成一个新的change-Id – linjiejun Dec 08 '21 at 09:05
-2

This should do it:

git commit --amend

Delete the change id and then push for review.

jherran
  • 3,337
  • 8
  • 37
  • 54
RoryThorn
  • 7
  • 1