Your editor says PORT=3000. The last commit says PORT=3000. You run git diff HEAD -- service.env and get a blank screen. Which port will a plain git commit record?

It can still be 8080. If CI builds that commit, the config it reads can differ from the one you just tested locally. One command lets you read the exact value before you commit:

git show :service.env 

That leading colon asks Git for the file in the index, the snapshot you have staged for the next commit. Here’s how to reproduce it in a few commands.

Change a port, then change your mind

Run this in Bash or Git Bash. It creates a temporary repository with its own commit identity.

cd "$(mktemp -d)" git init -q git config user.name "Git Lab" git config user.email "lab@example.invalid" printf 'PORT=3000\n' > service.env git add service.env git commit -qm "Set service port" 

Suppose you try port 8080, stage the change, then switch back to 3000 after a local test.

printf 'PORT=8080\n' > service.env git add service.env printf 'PORT=3000\n' > service.env git diff HEAD -- service.env 

The empty output is accurate. That command compares the file in your last commit with the file on disk. Both contain 3000. The copy you staged between those edits still contains 8080.

Read the two letters in Git’s clue

git status --short -- service.env 

Output from the lab:

MM service.env 

The first M means the staged file differs from the last commit. The second M means the file on disk differs from the staged file. If you had simply saved an edit and forgotten to stage it, only the second column would contain an M.

You can read the value at each point directly:

git show HEAD:service.env # last commit git show :service.env # staged snapshot cat service.env # file on disk 
PORT=3000 PORT=8080 PORT=3000 

For a longer config, use git diff --staged -- service.env to see just the lines the next commit would change. In this case it shows -PORT=3000 and +PORT=8080. That’s the change a reviewer would see if you committed now. Git’s diff reference

Keep 3000 and prove it

In this example, 3000 is the value you want to ship. The file on disk is already correct. Restore the staged copy from the last commit:

git restore --staged -- service.env git show :service.env git status --short -- service.env 

The first check prints PORT=3000. The status check prints nothing. All three copies now agree. In a real config with several edits, review the staged diff first: this restore unstages every staged change in that file. Git’s restore reference

If you’re getting comfortable with local commits and want to carry that understanding into team workflows on GitHub or GitLab, I wrote Git Mastery: From Zero to Expert — The Complete Guide to Git, GitHub & GitLab.

When have you caught a change in the staged diff that you would have missed by reading the file in your editor?