Is there a command that can take a ref and a file path, and output the full contents of the file as it was at that commit to STDOUT?
Eg. Something like this:
git show-me-the-file HEAD~2 some/file | do_something_with_piped_output_here
The Git Show command allows us to view files as they existed in a previous state. The version can be a commit ID, tag, or even a branch name. The file must be the path to a file. For example, the following would output a contents of a file named internal/example/module.go file from a tagged commit called “release-23”.
DESCRIPTION. In its first form, the command provides the content or the type of an object in the repository. The type is required unless -t or -p is used to find the object type, or -s is used to find the object size, or --textconv or --filters is used (which imply type "blob").
git show
e.g.
git show HEAD:./<path_to_file>
git show <ref spec>:<path>
for example, if you want to see a file at commit point 9be20d1bf62 you do:
git show 9be20d1bf62:a/b/file.txt
if you want to see file on particular branch:
git show <branch name>:<path>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With