Need Assistance?

support@tutorialshub.in

Git Fundamentals

Understanding git diff

ADVERTISEMENT
Git Free Lesson
5 min read
ADVERTISEMENT

Diffs show exactly what changed

A diff is a line-by-line description of changes. Git can compare the working tree with the staging area, the staging area with the last commit, or two arbitrary commits.

Two common comparisons

git diff shows unstaged changes. git diff --staged shows what is currently prepared for the next commit. These two commands together answer the common question: what did I change, and what am I about to commit?

Review is part of committing

Do not treat diffs as only a debugging feature. Reviewing a diff before a commit is a quality-control step that catches accidental formatting changes, temporary code and incorrect files.

ADVERTISEMENT