This question is related to the git/gerrit push command
When I submit my changes to the git/gerrit with the following command
git commit
git push origin HEAD:ref/for/master
It creates a commit.
Now if I want to amend any changes(creating a patch ).
I modify the file and uses the following command
git commit --amend
git log
It amends the detail in the same previous commit
But when I try to push it to the remote master with the following command
git push origin HEAD:ref/for/master
It creates a new gerrit commit instead of creating a patch for the previous commit
Am I missing something?
git commit --amend works, but, as mentioned here:
you need to add the gerrit
change-idat the bottom of your commit message (Change-Id: 234j243rasdf...) right before the git #'ed commit description and the change will be patched onto your previous commit –
See more about Change-Id in the Gerrit documentation.
During upload by pushing to a
refs/for/*orrefs/heads/*branch, Gerrit will use the Change-Id line to:
- Create a new change:
If this is the first time it has seen the Change-Id mentioned in the commit message, Gerrit will create a new change for review.- Update an existing change:
If Gerrit has seen this Change-Id before, but has not yet seen this new commit object, Gerrit will add the new commit as a new patch set on the existing change.- Close an existing change:
If Gerrit has seen this Change-Id before, and the commit is being pushed directly into a branch, the existing change is updated with the new commit, and the change is closed and marked as merged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With