Git push remote rejected {change ### closed}
Asked Answered
K

20

54

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://[email protected]:29418/xxxxxx
 ! [remote rejected] HEAD -> refs/for/master (change 14823 closed)
error: failed to push some refs to 'ssh://[email protected]:29418/xxxxxx'

any idea how i can fix this issue?

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

Kine answered 15/8, 2012 at 15:32 Comment(0)
M
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.

Morelock answered 2/4, 2014 at 12:40 Comment(3)
Just did the same thing. Cut and pasted the wrong Change-Id, then tried to push that.Hissing
My problem came from a cherry-pick that had to be amended on a repo using gerrit. Removing Change-Id is the answer.Horal
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.Brie
A
44

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
Affinity answered 9/8, 2016 at 9:41 Comment(2)
Work for me .Thk you.Bellanca
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.Resale
S
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!

Snack answered 15/8, 2012 at 15:39 Comment(7)
No joy. that change number is quite an old commit done by another devKine
What do you have in your commit comment? If it mentions that change number, it could be causing your issue.Snack
The answer do not have any solution to fix the issueChem
Yes it does. Just change your commit comment to not include any change-id and Gerrit will accept your commit. Sheesh.Snack
Thanks, that was exactly my case, don't know why it was downvoted, +1 from me!Ensample
FYI, the link in this answer goes nowhere now. This works: git.eclipse.org/r/Documentation/error-change-closed.htmlMarguerite
Yep, thanks for the updated link. It contains the same information... I'll edit my original answer.Snack
L
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

Lipography answered 3/5, 2016 at 8:23 Comment(1)
This worked for me. Seems gerrit is a bit of a mess to depend on commit messages for processing.Socialism
C
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
Coarse answered 25/11, 2018 at 17:28 Comment(0)
E
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.

Elmaleh answered 15/8, 2012 at 16:11 Comment(2)
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 griefKine
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.Elmaleh
R
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?

Ranunculus answered 28/8, 2012 at 9:47 Comment(1)
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.Atbara
B
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.

Biernat answered 26/8, 2013 at 17:42 Comment(0)
A
1

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

Amon answered 27/9, 2016 at 21:48 Comment(0)
I
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

Idaidae answered 1/9, 2022 at 18:7 Comment(0)
M
0

You're pushing to gerrit, which is a code review tool, as indicated by both the url (ssh://[email protected]: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.

Mountebank answered 15/8, 2012 at 18:15 Comment(0)
P
0

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

Pavilion answered 10/10, 2014 at 12:51 Comment(0)
J
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

Jeraldinejeralee answered 11/2, 2016 at 7:34 Comment(0)
S
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.

Sidney answered 1/9, 2016 at 13:19 Comment(0)
D
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.

Disaccredit answered 14/12, 2016 at 20:38 Comment(1)
I landed here and saw @johan's answer below, but wanted to spell out exactly what to do.Disaccredit
P
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.

Piracy answered 31/5, 2017 at 11:21 Comment(0)
J
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

Jaimeejaimes answered 18/10, 2018 at 5:44 Comment(0)
B
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.

Bellanca answered 8/12, 2021 at 9:4 Comment(1)
如果被close的commit不是最新的,--amend不能够解决。使用rebase交互模式中的reword子命令,来reword需要修复的commit。保存后弹出,需要进行重新编辑提交消息的时候,简单删除change-Id.保存,将会自动生成一个新的change-IdBellanca
W
0

Download the latest patchset (from gerrit) and repeat the stage,commit,push. This worked for me!!

Wyatan answered 9/4 at 3:25 Comment(0)
H
-2

This should do it:

git commit --amend

Delete the change id and then push for review.

Hellebore answered 2/12, 2015 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.