when we execute git log command, we see some information for each of the commit as below- Commit SHA-1 (Commit hash) Author Name and email Date Commit Title Commit Message Change-ID
I wanted to understand what is the difference between 1. Commit SHA-1 and 6. Change-ID.
It is independent of the commit id. To avoid confusion with commit ids, Change-Ids are typically prefixed with an uppercase I . Note that a Change-Id is not necessarily unique within a Gerrit instance. It can be reused among different repositories or branches (see below, change-upload).
@SergioTulentsev The commit ID is always exactly the SHA1 of the commit; in most contexts, you can specify an unambiguous prefix of the commit ID as an equivalent reference to the commit.
Gerrit allows attaching those 2 commits to the same change, and relies upon a Change-Id line at the bottom of a commit message to do so. With this Change-Id, Gerrit can automatically associate a new version of a change back to its original review, even across cherry-picks and rebases.
Commit SHA-1 (Commit hash) is a string that identifies a commit and is defined in a way that, if the commit is redone (with a amend, rebase or cherry-pick) or if anything in the commits history changes, the hash will be different.
Commit SHA-1 (Commit hash) is a string that identifies a commit and is defined in a way that, if the commit is redone (with a amend, rebase or cherry-pick) or if anything in the commits history changes, the hash will be different. So, if you checkout a hash, you can be confident that you check out exactly the same commit with the same history. More info here: https://gist.github.com/masak/2415865
Gerrit Change-Id is also a hash string, but it is not part of git. It is something that is added later to commit messages so Gerrit can read it. This is only used by Gerrit. The use is the following. I make a new commit and send it to Gerrit. It has the Change-Id abc
. When reviewed, if this commit has an issue, I have to fix it. The way I would do it is, amend the current commit. Amending will change the commit's SHA-1 but will not change the Change-Id if I do not change the commit message. Since now this new commit shares the same Change-id, when I send it to Gerrit, Gerrit will know that this new commit is a new version of the change abc
and will group them together to facilitate reviewing.
More info here: https://git.eclipse.org/r/Documentation/user-changeid.html
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