Git push remote rejected {change ### closed}

Viewed 96906

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.

19 Answers

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

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

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

Related