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) ?

  • git checkout? git archive? – Mikel Apr 12 '14 at 13:07

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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