Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have cloned a xorg git repository:

git clone git://anonscm.debian.org/pkg-xorg/driver/xserver-xorg-video-intel

and I need to extract all files as they looked after commit 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f

I know how to extract one file of a specified version, i.e.

git show 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f:src/intel_driver.h > intel_driver.h

but how can I extract the whole structure (all files) ?

share|improve this question
    
git checkout? git archive? –  Mikel Apr 12 at 13:07

1 Answer 1

up vote 2 down vote accepted

To check out a specific commit:

git checkout 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f

This will report an error if it would need to overwrite files that are not committed. To unconditionally overwrite file, pass the -f option.

To extract a commit without affecting the working copy:

git archive 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f | gzip >../45c09bfe58c37bbf7965af25bdd4fa5c37c0908f.tar.gz
git archive --prefix=45c09bfe58c37bbf7965af25bdd4fa5c37c0908f/ 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f | tar xf - -C ..

git archive gives you a tar archive, which you can extract elsewhere or store to a file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.