How to clone git repository with specific revision/changeset?

John picture John · Aug 15, 2010 · Viewed 504.1k times · Source

How can I clone git repository with specific revision, something like I usually do in Mercurial:

hg clone -r 3 /path/to/repository

Answer

Vaibhav Bajpai picture Vaibhav Bajpai · Dec 30, 2012
$ git clone $URL
$ cd $PROJECT_NAME
$ git reset --hard $SHA1

To again go back to the most recent commit

$ git pull