paperlined.org
apps > git
document updated 8 months ago, on Feb 12, 2024

Instead of looking at commits first, start by looking at a specific file, perhaps across commits.

Across several commits

How do you list the history for a specific file?

git log -- $FILE

How do you view a list of files modified by one or more commits?

There are several ways to do this, but my favorite — git log --name-only

How do you look at the diff for just one file?

git diff <revision> <path>

For example — git diff b0d14a4 foobar.txt

Or:

git diff <revision1>:<path> <path>

For example — git diff b0d14a4:foobar.txt foobar.txt

Within one commit

How do you look at a specific version of a specific file?

git show $REV:$FILE