Troubleshooting Gerrit Push Rejections Due to Reused Change-Ids

When attempting to upload modifications to a Gerrit code review server, users may encounter a remote rejection error indicating that a specific change record is already closed. This typically occurs when the commit message contains a Change-Id that corresponds to a previous submission which has already been merged or abandoned.

The error output generally resembles the following:

To ssh://review.example.com
 ! [remote rejected] HEAD -> refs/for/main (change http://review.example.com/+/54321 closed)

In this scenario, the remote server identifies that the Change-Id attached to the commit is associated with an existing, closed record. Since Gerrit requires unique identifiers for new changes on the same branch, the push is blocked. To proceed, the commit metadata must be updated to generate a fresh identifier.

Updating the Most Recent Commit

If the problematic commit is the latest one in your local branch, you can modify it directly using the amend command. Execute the following in your terminal:

git commit --amend

This action opens the default text editor with the current commit message. Locate the footer line containing the existing identifier, which looks similar to this:

Change-Id: I9f8e7d6c5b4a3210fedcba9876543210abcdef12

Delete this entire line, then save and close the editor. Upon completion, the Git hooks will automatically append a new, unique Change-Id to the message, allowing the push to succeed.

Updating Older Commits via Rebase

If the commit requiring modification is not the most recent one (for example, it is 20 commits back in the history), an interactive rebase is necessary. Initiate the rebase process targeting the appropriate depth:

git rebase -i HEAD~20

The editor will display a list of commits with instructions. By default, each commit is marked with pick. Locate the specific commmit causing the conflict and change the command from pick to reword. The list might look like this:

pick a1b2c3d Implement user authentication
pick e4f5g6h Update database schema
reword h7i8j9k Fix validation logic error
pick l0m1n2o Refactor API endpoints

Save and close the rebase todo list. The editor will reopen for the selected commit message. Similar to the amend process, remove the old Change-Id line:

Change-Id: I1234567890abcdef1234567890abcdef12345678

After saving and exiting, the rebase will continue, and a new identifier will be generated for that specific commit, resolving the conflict with the closed change record.

Tags: Git gerrit code-review change-id version-control

Posted on Wed, 20 May 2026 06:35:30 +0000 by ragear