Git push remote rejected {change ### closed}

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.


Solution 1:

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.

Solution 2:

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

Solution 3:

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!

Solution 4:

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

Solution 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