git,

How to Git checkout a commit

Sep 01, 2022 · 1 min read · 21 views · Post a comment

Besides checking out Git branches, checking out commits could be a convenient way to test and deploy features in a test environment as well. As with branches, we are going to use the git checkout command for commits too. The only thing you need to figure it out is the commit ID which presents a SHA-1 hash.

Prerequisites

  • Git

Solution

Step 1. First, find the commit ID (hash). This can be done by listing all commits in a Git repository.

Step 2. Go to your repo directory and run the following command:

git checkout <commit-SHA1>

Another useful post might be How to get the current commit hash in Git.

Conclusion

To find more neat Git commands and hacks, browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.

git