Checkout old commit for temporary directory with git

My sources are in /home/user/Workspace/MyProject and the git repository is in /home/user/Workspace/MyProject/.git .

Now I want to get an older commit, but get it in /home/user/Workspace/MyProject_OldCommit , because I don't want to change anything in the MyProject directory.

+4
source share
2 answers
 cd /home/user/Workspace git clone MyProject MyProject_OldCommit cd MyProject_OldCommit git checkout <old_sha1> 
+7
source

Run this from /home/user/Workspace/MyProject :

 git archive <old-sha1> | tar -x -C ../MyProject_OldCommit 

This will create a new commit copy without the whole git repository.

+2
source

All Articles