I want to change the last commit content. I can do local changes. and then execute
git commit --amend
I can also do the following:
git rebase -i HEAD~
choose the commit to edit. do local changes and then execute:
git rebase --continue
No. They both use the previous commit as a template to generate a new commit. The Gerrit change-id is simply tracked by the line in the commit comment so provided you don't modify or remove that line Gerrit can still track this new commit as referring to that change.
suppose you have 3 commits A->B->C, and you have change a file which is included in commit A, so, you should make commit A at the top
git stash /* to save your changes */
git rebase -i HEAD~3
move commit A at the bottom of commits B&C
save&exit
if you make
git log
you wil have this sequence B->C->A, you make
git add /*your changed file*/
git commit --amend
now you must return commit A back to not change gerrit dependencies list
git rebase -i HEAD~3
move commit A at the top of commit B&C
save&exit
now if you push to gerrit, you will have the same old order
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