Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do get a clone of a commit from history github

I want to clone, that is get all the files from a push 1 week ago onto my computer, I know the SHA, I just need a way to get those files onto a directory on my local machine. Is there a simple way to do this?

like image 992
Alex Borsody Avatar asked Oct 18 '11 22:10

Alex Borsody


People also ask

Does git clone copy commit history?

Each clone usually includes everything in a repository. That means when you clone, you get not only the files, but every revision of every file ever committed, plus the history of each commit.

How do you view the commit history of a cloned repository?

After you have created several commits, or if you have cloned a repository with an existing commit history, you'll probably want to look back to see what has happened. The most basic and powerful tool to do this is the git log command.


1 Answers

you just use the archive after you clone:

git archive <sha1 you want> | tar -x -C /some/path/to/save/to

if you want to actually work on the repository, checkout the commit:

git checkout <sha1 you want>

Just be careful as now you are not on any branch. You need a branch to push and pull and track your commits. So make a branch first and then check it out:

git branch mywork <the sha1 you want>
git checkout mywork

or in one line:

git checkout -b mybranch <sha1 you want>
like image 81
Adam Dymitruk Avatar answered Nov 16 '22 02:11

Adam Dymitruk