This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log
Sometimes I need to pull a complete copy of a previous file out of a github (this is useful when needing to do visual binary diffs to see which bytes have moves or changed).
To pull a specific file, say the last commit, the following command line does the trick:
git show HEAD^:./myfile.bin > myfile.bin
The HEAD^
means "one commit behind the head of the branch" (the "head" being the last commit on the branch). Though if you've got merge commits where a commit has more than one parent commit this can get a little complicated (which why I tend to stick to just the previous commit).
Using HEAD^^
or HEAD^2
means "two commits before the head of the branch". There's also detailed stackoverflow post about the difference between the caret ^
and the tilde ~
with examples of how they traverse up the tree.
Originally published on Remy Sharp's b:log
This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log

remy sharp's b:log | Sciencx (2021-07-02T09:51:37+00:00) Extracting previous copy from github [til/cli]. Retrieved from https://www.scien.cx/2021/07/02/extracting-previous-copy-from-github-til-cli/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.