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