What's the difference between 'Commit ID' and 'SHA1 Hash' in GIT?

cryptography, git

Solution

Commit ID is what identifies a commit. Sometimes, you will see the shorthand version which is just the first seven characters of the actual commit ID versus the full hash.

Consider the following example:

[master 42e2e5a] Added a new readme file to illustrate commit IDs.
1 file changed, 1 insertion(+)
create mode 100644 myreadme

Notice it is showing the shorthand version of the commit ID. Because the actual commit ID is forty hexadecimal characters that specify a 160-bit SHA-1 hash.

Example

Full commit ID

git show -s --format=%H

Result

42e2e5af9d49de268cd1fda3587788da4ace418a

Shorthand version

git show -s --format=%h

Result

42e2e5a

But notice they are the same.

Problem

I've been working on GIT for quite sometime now. However, I could not find difference between 'Commit Id' and 'SHA1 - hash value' What is the difference between 'Commit ID' and 'SHA1'? Any simple explanation with an example would be nice

Original source

Related problems