Guides · git
How to see what changed before you commit
By Lalla Asmaa Alaoui, founder of Mel · Updated
Run git diff to see changes you have not staged yet, and git diff --staged to see exactly what will go into your next commit. Read both before you commit, and you will never ship a stray debug line or a file you did not mean to touch.
This habit matters even more when an AI agent edits your code. The diff is the one honest record of what changed, whoever made the change. The commands below are the same on Mac, Linux and Windows.
Steps
- Get the overview with git status.
git statusGit lists three groups: changes staged for commit, changes not staged, and untracked files (new files git does not follow yet). Start here so nothing surprises you later.
- See which files changed, and how much.
git diff --statThis prints one line per file with a count of added and removed lines. A file you did not expect, or a huge count, is your first warning sign.
- Read the unstaged changes.
git diffLines starting with - were removed and lines starting with + were added. Press space to page down and q to quit the pager. To read one file only, add its path:
git diff src/app.js- Stage what you want, piece by piece.
git add -pGit shows each change (a "hunk") and asks what to do. Type y to stage it, n to skip it, s to split it smaller, or q to stop. This is the best way to keep one commit about one thing.
- Read what will actually be committed.
git diff --staged--cached means the same thing. This is the final check: it shows exactly the changes your next git commit will record, and nothing else.
- See everything since the last commit at once.
git diff HEADThis combines staged and unstaged changes against your last commit.
- Check new files too.
git diffdoes not show untracked files. Look at them ingit status, and open them to read them. Once yougit adda new file, it appears ingit diff --staged.
- Commit.
git commit -m "Explain what changed and why"Useful extras
- Compare your branch with main:
git diff main...HEADshows what your branch added since it split frommain. - Word-level changes:
git diff --word-diffhighlights changed words instead of whole lines, which helps with prose and config files. - Names only:
git diff --name-onlylists changed file paths, handy in scripts. - No pager:
git --no-pager diffprints straight to the terminal.
On Windows, these commands work the same in Command Prompt, PowerShell and Git Bash. If colours do not show, run git config --global color.ui auto.
Doing it with Mel
In Mel you can run every command above at the prompt. Each one becomes a block, so a long git diff output stays in one place you can scroll, filter or copy.
Mel also has a code review panel for exactly this job. Press ctrl+shift+= (cmd+shift+= on macOS), or click the change count on the git chip above the prompt. The panel opens beside your terminal and shows every uncommitted change as a card per file, with added and removed line counts and syntax highlighting. New untracked files appear too, as all-added cards. A dropdown switches the base, so you can compare against another branch instead.
When Mel's agents edit files, each applied edit also shows a diff card in the conversation. The review panel then shows the combined result, yours and the agents', before you commit. Hover a line and click the comment button to leave a note, and Send to Agent passes all your notes back as one prompt.
FAQ
What is the difference between git diff and git diff --staged? git diff shows changes in your files that are not staged yet. git diff --staged shows changes that are staged and will go into the next commit.
Why does git diff show nothing? Either nothing changed, or all your changes are already staged. Try git diff --staged, or git diff HEAD to see both.
How do I see changes in new files? git diff ignores untracked files. Stage them with git add, then run git diff --staged, or open them directly.
How do I see what changed in the last commit? Run git show for the latest commit, or git show <commit-id> for an older one.
How do I stage only part of a file? Run git add -p and answer y or n for each change. Use s to split a change into smaller parts.
- How to review an AI agent's code changes
- How to undo the last git commit
- How to discard local changes to a file in git
- What is a coding agent?
Facts checked on Oct 25, 2026.
Git is a trademark of its owner. Mel is not affiliated with or endorsed by Git.
Mel – the agentic terminal · openmel.dev. A multi-agent, multi-model AI terminal for Mac, Windows, Linux and VS Code. Free with your own API key.

Lalla is a hands-on tech founder, agentic infrastructure architect and the vision behind Mel.
Follow on LinkedIn