What command is used to show the contents of a specific file at a specific commit?
Posted by IreneSm
Last Updated: June 08, 2024
In Git, you can use the git show command to display the contents of a specific file at a specific commit. The syntax is as follows:
git show <commit-hash>:<path-to-file>
- <commit-hash>: Replace this with the actual hash of the commit you want to reference. - <path-to-file>: Replace this with the path to the file relative to the repository root. For example, to show the contents of example.txt at commit abcd123, you would use:
git show abcd123:example.txt
This will display the contents of example.txt as it was at that specific commit.