Skip to content
Justice Tech School

Listing and Showing Files

git ls-files lists tracked files. git show REV:path prints a file as it was in a commit, without checking it out.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'Second'
git ls-files
git show HEAD~1:a.txt
git show HEAD:a.txt

Result

a.txt
one
one
two

Exercise

Print a file from the last commit.

git show HEADa.txt

Quiz Test

What does HEAD~1 mean?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.