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
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
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.
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.
I've read the answers provided before and I think there's a little thing to add to them. A revision always points to a sha1 (it doesn't actually point, a revision is identified by its sha1 ID but bear with me) but objects in git's DB can be: revisions, trees, blobs, etc and they are all identified by sha1 IDs. So a revision implies using a sha1 ID (to identify it... but there are other sha1 IDs used in a revision like for parents, tree object) but a sha1 ID doesn't necessarily mean it's a revision.