optimus optimus - 12 days ago 7
Git Question

Push under same change id after merge conflict

I am using

git
and
gerrit
for code reviews. After pushing a change with a unique
change id
, there was a merge conflict issue on
gerrit
dashboard. So I pulled code again and resolve the merge conflict and then decided to amend the changes under the same change id, but
git
won't allow this.
Amend
cannot be done if there is a
merge conflict
. You have to do a separate commit.
So is there any way to push my updated code under the same
change id
?

Answer

I think you are confused "Change-Id" (Gerrit) with "Commit-Id" (Git). When you resolved the conflict and amended the original commit a new commit was generated with, of course, a new Commit-Id. You can (actually, you need) keep the same Change-Id at the commit message last line, like for example:

Change-Id: Id65100bb3841c73bb9dd2d2d6a69c77a5936681a

When you push this commit to Gerrit, it will use this line to know that this commit is an amend (new patchset) of the original one and it will add this to the original change.

See more info here.

Comments