Git: Show Difference Between Files
Here's how to diff between various areas of git.
here's some important concepts of areas/states for diff to work on (All are local on your computer):
- Working Directory (aka Working Tree)
- Files in your project's directory.
- Index (aka Staging Area)
-
A virtual area (a index file) that
git add
is placed into. - Commit ID
- A specific commit. 〔see Git: Commit ID〕
- HEAD
- A variable that usually refers to the last commit of current branch. 〔see Git: What's HEAD〕
Diff Between Areas
Diff workingDir vs lastCommit
git diff --color commitID
- diff workingDir vs lastCommit. Replace the commitID by HEAD, for lastCommit.
Diff Between 2 Commits
git diff ID1 ID2 filename
- diff between 2 commits. 〔see Git: Commit ID〕
Diff workingDir vs Index
git diff --color
- diff workingDir vs Index
git diff --color filename
- diff workingDir vs Index, 1 file
Diff Index vs lastCommit
git diff --color --staged commitID
- diff Index vs lastCommit
Show Changed Files
git status
- Show state of {Index, workingDir, lastCommit}
2014-01-18 Thanks to Nick Alcock for review.