Git Diff & Delta on Linux: Reading Code Changes Without GitHub Desktop
A complete guide to Git Diff and Git Delta on Linux to review code changes comfortably without GitHub Desktop.
If youβve stopped using GitHub Desktop and moved fully to the terminal on Linux π§, mastering git diff is non-negotiable.
git diff lets you inspect what changed, where, and howβdirectly from the command line π».
Combined with Delta, it becomes clean, readable, and editor-like β¨βwithout any GUI.
π This article covers:
- π§ Git diff fundamentals
- π§ Commands youβll use daily
- π¨ Installing & configuring Delta
- β‘ A clean terminal-based workflow
π§ 1. What Is Git Diff (Delta)?
In Git, a diff (delta) represents the difference between two states of your code.
Conceptually, Git works in three layers:
π Working Directory β π¦ Staging Area β ποΈ Repository (Commit)
git diff allows you to compare changes between any of these layers π.
π§ͺ 2. Essential Git Diff Commands
πΉ 2.1 View unstaged changes
git diff
Compares:
π Working Directory vs π¦ Staging Area
Use this to:
- π Review code before staging
- π Catch mistakes early
πΉ 2.2 View staged changes
git diff --staged
# or
git diff --cached
Compares:
π¦ Staging Area vs ποΈ Last Commit
Perfect for double-checking before commit β .
πΉ 2.3 Diff a specific file
git diff app.py
Multiple files or directories:
git diff src/ tests/
πΉ 2.4 Diff between commits
git diff COMMIT_1 COMMIT_2
Example:
git diff HEAD~1 HEAD
π₯οΈ This replaces βCompare commitsβ in GitHub Desktop.
πΉ 2.5 Diff between branches πΏ
git diff main..feature/login
Or explicitly:
git diff main feature/login
Ideal for pre-merge reviews π.
πΉ 2.6 Summary-only diffs
Only file names:
git diff --name-only
With status:
git diff --name-status
Example output:
M app.py
A auth.py
D old_utils.py
π¨ 3. Making Git Diff Readable with Delta
Default Git diff output can be painful to read π΅. Delta upgrades it with:
- π Syntax highlighting
- βοΈ Side-by-side view
- π’ Line numbers
- π§ Keyboard navigation
Once you try it, youβll never go back π―.
π¦ 4. Installing Delta on Linux
π§ Ubuntu / Debian
sudo apt install git-delta
πΉ Arch Linux
sudo pacman -S git-delta
π© Fedora
sudo dnf install git-delta
Verify installation:
delta --version
βοΈ 5. Set Delta as the Default Diff Viewer
Enable Delta globally:
git config --global core.pager delta
Recommended settings β:
git config --global delta.side-by-side true
git config --global delta.line-numbers true
git config --global delta.syntax-theme Dracula
git config --global delta.navigate true
git config --global delta.light false
π Now every git diff looks beautiful.
π§© 6. Recommended Git Configuration (Full Setup)
Edit global config:
git config --global --edit
Add:
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
side-by-side = true
line-numbers = true
syntax-theme = Dracula
[diff]
colorMoved = default
π§ This feels like a modern code review toolβright in your terminal.
π 7. Daily Git Workflow (No GUI Needed)
A clean, safe workflow π‘οΈ:
git status
git diff
git add .
git diff --staged
git commit -m "feat: add login validation"
git push
Check recent commits:
git log --oneline --graph --decorate -5
β‘ 8. Useful Git Diff Aliases
Work faster with aliases ποΈ:
git config --global alias.d "diff"
git config --global alias.ds "diff --staged"
git config --global alias.dc "diff HEAD~1"
Usage:
git d
git ds
git dc
π 9. GitHub Desktop vs Terminal
| GitHub Desktop π±οΈ | Terminal π» |
|---|---|
| View Changes | git diff |
| Staged Changes | git diff --staged |
| History | git log |
| Compare Branches | git diff main..feature |
Terminal workflows are faster, scriptable, and customizable π.
π§Ύ 10. Bonus: Inspect a Commit Directly
Latest commit:
git show HEAD
Specific commit:
git show <commit-hash>
Includes diff + metadata π.
π Conclusion
If you:
- π§ Use Linux
- π» Love the terminal
- π― Want full Git control
Then Git Diff + Delta is a must-have skill π.
Once set up, code reviews become:
- β‘ Faster
- π§Ό Cleaner
- π§ More reliable than GUI tools