Commit Hash

Learn how each commit in Git is associated with a hash and how that makes Git a very powerful tool for version control.

What is a commit hash?

For each commit, Git generates a SHA-1 hash as the commit identifier. The hash is based on the current time, the author, the parent commit ID, and some other information.

The commit hash is generated by Git automatically. We get a new hash each time. For example, if we create a commit and then delete it and commit again, we’ll get a different commit hash.

How can we use it?

When we refer to a specific commit, we can use the initial several characters to refer to it.

In the terminal given below, run the following command:

$ git log

Get hands-on with 1400+ tech skills courses.