Every git commit has a hash like '3f7a2b1'. It's not random — it's a cryptographic snapshot.
Git hashes your code changes, the commit message, author, timestamp, and parent commit(s). All of this gets hashed together.