Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

10 November 2026 · One command a day

How do I see exactly which lines changed in my files with git diff?

git diff shows you, line by line, what has changed in a git repository since the last commit. You reach for it before you commit, before you restart a service after editing its config, or when you find a server folder that someone has been editing by hand. git status tells you which files changed. git diff tells you what changed inside them.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

cd /var/www/sitename
git diff
git diff --staged
git diff -- nginx/sitename.conf

Run it from inside the repository. Plain git diff compares your working files with the staging area. That means it shows edits you have not yet added with git add. --staged (the same as --cached) shows what you have already added, which will go into the next commit. A -- followed by a path limits the output to one file or folder. The double dash tells git that what follows is a path, not a branch name. If another user owns the repository, run the command as that user, for example sudo -u appname git diff. If you run it as root instead, git may refuse with a dubious ownership warning.

What you will see

diff --git a/nginx/sitename.conf b/nginx/sitename.conf
index 4e1c2a9..b7d03f5 100644
--- a/nginx/sitename.conf
+++ b/nginx/sitename.conf
@@ -3,7 +3,8 @@ server {
     server_name example.com www.example.com;
     root /var/www/sitename/public;
 
-    client_max_body_size 2m;
+    client_max_body_size 20m;
+    proxy_read_timeout 120s;
 
     location / {
         proxy_pass http://127.0.0.1:3000;

Each file starts with a diff --git header. The --- line is the old version and the +++ line is the new one. @@ -3,7 +3,8 @@ means this chunk starts at line 3 and covers 7 lines before the change and 8 after it. Lines starting with - were removed. Lines starting with + were added. Lines starting with a space did not change and are shown for context. An edited line appears as one removal followed by one addition. The output opens in a pager, and you press q to leave it.

When to use it

Watch out for

Plain git diff goes quiet once you run git add. The changes have not gone anywhere. They have moved to the staging area, so you need git diff --staged to see them. Brand new files that git does not track yet appear in neither view until you add them, so check git status as well.

Questions people ask

How do I see only the names of the changed files?

Use git diff --name-only for a plain list. git diff --stat lists the same files with a count of added and removed lines for each.

How do I compare my files with an older commit?

Give git a commit to compare with. For example, git diff HEAD~3 compares your working files with the state three commits ago. Hashes from git log --oneline work too.

Reviewing changes to live config files line by line takes shell access to a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I see what has changed in a git repository before I commit? · How do I check what a domain resolves to from the command line? · How do I copy a git repository onto my Linux server? · All daily notes