Getting contents of a file in a specific commit in Git

git-show command can be used to to display contents of a file in a specific commit

Command syntax

# Get contents of a file in a specific commit.
# <commit>, the commit, such as an commit id.
# <file-path>, file path relative to the current directory.
$ git show <commit>:<file-path>

Examples

# Get contents of asset/css/style.css in commit 8bc723c
$ git show 8bc723c:asset/css/style.css

# Get contents of asset/css/style.css in the parent commit.
$ git show HEAD~:asset/css/style.css