Introduction to Git
George Boorman
Curriculum Manager, DataCamp
git diff
- Difference between versions
git diff report.md
report.md
to the staging areagit add report.md
report.md
with the version in the staging areagit diff --staged report.md
git diff --staged
Find the commit hashes
git log
Compare them
git diff 35f4b4d 186398f
What changed from first hash to second hash
HEAD
git diff HEAD~1 HEAD
Command | Function |
---|---|
git diff |
Show changes between all unstaged files and the latest commit |
git diff report.md |
Show changes between an unstaged file and the latest commit |
git diff --staged |
Show changes between all staged files and the latest commit |
git diff --staged report.md |
Show changes between a staged file and the latest commit |
git diff 35f4b4d 186398f |
Show changes between two commits using hashes |
git diff HEAD~1 HEAD~2 |
Show changes between two commits using HEAD instead of commit hashes |
Introduction to Git