When searching for ways to export a specific commit (specified by its sha
) to a directory, I get very many pointers, each with very many answers.
Possibly, that's because such questions are under specified, making multiple answers possible.
Here is what I do not want to do:
- I don't want to clone my multi-gigabyte repo and then checkout. I'd like to checkout to a directory from the present repo.
- The
sha
I'd like to extract is marked by neither atag
nor abranch
. In fact, thesha
I want is still hazy. Several are candidates.
Indeed simply running git show a1b2c3c:path/to/file/myfile.c
(which extracts a specific file from a specific commit) already does what I want, except that:
- I'd like to extract a full tree (from root), not just one file.
git show
sends files to the terminal. I'd like to save to/tmp
.
My question then is: How do I extract all files in a sha
to /tmp
?
To provide motivation, let me mention a few use cases for this questions. These are my problem; they're not the question!
- I gave an improvised demo in the (perhaps distant) past and I'd like to determine the point the project was at.
- I had omitted to add a given file to the repo, and it sometimes takes quite a while to notice that a file was not added. I'd like to track when the file went missing.