How do I print a file from another branch with git?

Viewed 77

I know there's git cat-file but it takes a sha

what I want to do is something like git cat-file mybranch -- path/to/myfile.txt which would accomplish the same thing as

git checkout mybranch && cat path/to/myfile.txt

except it wouldn't actually checkout the branch. How can I do this?

1 Answers

You can do it in many ways:

git cat-file blob mybranch:path/to/myfile.txt

or

git show mybranch:path/to/myfile.txt
Related