Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to in Git, clone a remote (GitHub) repository from a specifed date

Tags:

I'm trying to clone a git repository from a certain date. Even if this is not possible. Is it possible to clone the git repository and then roll it back to a certain date?

Example: my repository has been updated since May 2010, but I'd like to get the version from June 5th. I'd like to run the following command:

git clone [email protected]:projectfolder -date 06-05-2010 
like image 953
Matt Wear Avatar asked Sep 24 '10 20:09

Matt Wear


2 Answers

Cloning the repository will give you the entire commit history of all the source code.

You need only scroll back through git log and find the desired commit on your target date. Running git checkout SHA where SHA is the commit hash will give you the state of the source code on that date.

edit:

git log --since=2010-06-05 --until=2010-06-06 will help narrow it down!

like image 63
Jake Wharton Avatar answered Sep 20 '22 18:09

Jake Wharton


Maybe something like this:

git log --since=2010-06-05 --until=2010-06-05

Find one of the commit ids you like there then do a git checkout <checkout id>

like image 29
Chuck Vose Avatar answered Sep 22 '22 18:09

Chuck Vose