How to Checkout/Clone From a Specific Git Commit Id (SHA)

1 Year Subscription

There are scenarios where you might need to checkout or clone from a specific git commit id.

This blog explains the steps involved in checking out a specific git commit ID (SHA).

Important Note: Always keep a backup of your code with all the commit histories before performing any git activity that may change or reverse the code.

Checkout From Specific Git Commit ID

Follow the steps to checkout from a specific commit id.

Step 1: Clone the repository or fetch all the latest changes and commits.

Step 2: Get the commit ID (SHA) that you want to checkout. From your local repository, you can get the commit SHA from the log. If you are using any platforms like Github, you can get the SHA id from the GUI itself.

git log
git commit ids min

Step 3: Copy the commit (SHA) id and checkout using the following command.

git checkout 28cd74decb47d8a5294eb59e793cb24a0f242e9e

You can also use the short form of the SHA ID from the start, as shown below.

git checkout 28cd74de



Continue reading on source link

Leave a Comment

Your email address will not be published. Required fields are marked *

+ 86 = 91