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 IDs are unique SHA-1 hashes that are created whenever a new commit is recorded. If you specify a commit ID when you add a repository, Domino will always pull the state of the repository specified by that commit in a detached HEAD state.
The algorithm that Git uses is the SHA-1 hash algorithm which basically is a cryptographic hash function taking input and producing a 160-bit (20-byte) hash value.
Learn how to find the hash of a git commit To find a git commit id (or hash), you can simply use the git log command. This would show you the commit history, listing the commits in chronological order, with the latest commit first.
commit is. A commit, or "revision", is an individual change to a file (or set of files). It's like when you save a file, except with Git, every time you save it creates a unique ID (a.k.a. the "SHA" or "hash") that allows you to keep record of what changes were made when and by who.
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.
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