How can I clone git repository with specific revision, something like I usually do in Mercurial:
hg clone -r 3 /path/to/repository
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UPDATE 2 Since Git 2.5.0 the feature described below can be enabled on server side with configuration variable
uploadpack.allowReachableSHA1InWant, here the GitHub feature request and the GitHub commit enabling this feature. Note that some Git servers activate this option by default, e.g. Bitbucket Server enabled it since version 5.5+. See this answer on Stackexchange for a exmple of how to activate the configuration option.UPDATE 1 For Git versions
1.7 < v < 2.5use git clone and git reset, as described in Vaibhav Bajpai’s answerIf you don’t want to fetch the full repository then you probably shouldn’t be using
clone. You can always just use fetch to choose the branch that you want to fetch. I’m not an hg expert so I don’t know the details of-rbut in git you can do something like this.