git show a file at a specific commit
Quick Answer
# Print the file contents at a specific commit
git show abc1234:src/app.ts
# Restore a file from a past commit into your working directory
git checkout abc1234 -- src/app.ts
When to use this
You want to inspect or recover a file as it looked at a past commit — without switching branches.
Other causes & fixes
Save the old version to a different filename
git show abc1234:src/app.ts > src/app.old.ts
Show a file from a tag or branch
git show v1.2.0:src/app.ts
git show main:src/app.ts
See all files changed in a commit
git show --name-only abc1234
Related