Check Out a Specific Commit

Learn to check out specific commits to move to the previous state of files in the repository.

The git checkout with commit hash

We can check out specific commits by using the following command:

$ git checkout <commit hash>

The commit hash is 40 alphanumeric characters long. We don’t necessarily need to write all 40 characters. We just need to include the first few characters to allow Git to identify that commit. For example, git checkout a1b2c3 would be enough most of the time to identify a unique commit.

Get hands-on with 1200+ tech skills courses.