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

Answers


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.


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

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!


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


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.


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?


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.


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.


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


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


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.


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


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.


Solution for EGit users:

  1. Click Amend button

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

  3. Commit your changes & push.


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


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

This should do it:

git commit --amend

Delete the change id and then push for review.


Need Your Help

Android to Android TCP Connection

android sockets tcp connection

All of the documentation, examples and questions I've seen so far on TCP connections with Android have been between an Android device and a computer. As unreliable as wireless can be, is it possibl...

ListView scroll to bottom as all binding data loaded

c# xaml listview binding windows-phone-8.1

I have a ListView in my xaml which is binded to ReadOnlyObservableCollection which contains items.