What is a commit hash, and why is it such a long string?
A commit hash is a SHA-1 fingerprint of the commit's contents, author, message and parent. It uniquely identifies the commit and changes if anything inside it changes. You can usually use just the first 7 characters.
Explain it simply
A hash is like an Aadhaar number for a commit, except it is calculated from the commit itself rather than handed out. Git feeds the snapshot, the author, the date, the message and the parent's hash into SHA-1 and gets 40 hexadecimal characters.
That has two consequences. First, two different commits practically never share a hash. Second, because the parent's hash is part of the input, changing an old commit changes every hash after it. That is why rebasing rewrites history and why Git can detect corruption.
Typing 40 characters is painful, so Git accepts any unique prefix, commonly 7 characters. Newer Git can use SHA-256, but SHA-1 is still the default.
Example
git log --oneline
# 3f9c2ab Add payment page
# 81d04e7 Fix cart total
git show 3f9c2ab # short prefix is enough
git rev-parse HEAD # full 40-character hashWhat to say in the interview
"A commit hash is a SHA-1 checksum computed from the commit's content, metadata and parent hash. It identifies the commit uniquely, and since it includes the parent, changing any old commit changes all later hashes. In daily use I type only the first seven or so characters."