Ad space (banner)
🌿Git Lessons
Lesson 53 / 59

Viewing One File's Diff with git diff <file>

This lesson covers narrowing a diff down to just one file with git diff <file>. It's for anyone searching "git diff specific file usage."

git diff filename narrows the diff down to just one file, out of several that have changes, so you can review it in isolation.

In Try It, run git diff app.js. Only the changes to the file app.js are shown, separated out from any changes in other files.

A common early mistake is spending a lot of time hunting for the file you want inside a giant combined diff, after changing many files — specifying the filename removes that hassle entirely. In real teams, "I just want a final check on this one file" comes up often during a large change, making this command a routine, everyday tool.

Git
Try it (type this into the pseudo terminal)
git diff app.js

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)