8 November 2026 · One command a day
How do I see what has changed in a git repository before I commit?
git status shows the state of a git repository: which files you have changed, which are staged for the next commit, and which git is not tracking yet. Run it before every commit, and any time you are not sure what has been edited on a server.
I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.
The command
cd /var/www/appname
git statusThe cd moves you into the folder that holds the repository. Git looks upwards from there for the .git folder, so any subfolder of the project works too. git status takes no arguments for the full report. Add -s for a short report with one line per file, and -b to keep the branch line in that short form. git status -sb is a common everyday version.
What you will see
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: config/nginx.conf
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: public/index.html
deleted: scripts/old-deploy.sh
Untracked files:
(use "git add <file>..." to include in what will be committed)
backup.sqlRead it from the top. The first lines give the branch and say whether it is ahead of or behind the remote copy. Changes to be committed is what goes into the next commit. Changes not staged for commit are edits git knows about that you have not added yet. Untracked files are new files git has never seen. In this example, backup.sql should probably not be committed at all. If everything is clean, git says nothing to commit, working tree clean.
When to use it
- Just before
git commit, to check that only the files you meant to change are staged. - After a deploy or an update, to see if anything edited files on the server directly.
- Before a
git pull, so local edits do not block the pull or get mixed in with incoming changes.
Watch out for
A clean status does not mean nothing changed on disk. Files listed in .gitignore, such as .env, uploads or node_modules, never show up in the normal report. If you need to see them as well, run git status --ignored. Also check the untracked list before you run git add .. That command stages everything in the list, including database dumps and secrets.
Questions people ask
Does git status change anything?
No. It reads the repository and your files and reports on them. It does not stage, commit or delete anything.
Why does git status say "detected dubious ownership"?
The repository belongs to a different user from the one running git, which often happens when you work as root. Run git as the owner instead, as shown in running commands in a folder owned by another user, or fix the file ownership if root created the files by mistake.
Checking a live repository directly on the machine that serves your site is only possible on 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.
Affiliate link.