Git diff (original) (raw)

Last Updated : 7 May, 2026

git diff is a Git command used to compare changes between different states of a repository, helping developers see what has been modified in files before committing or merging.

head

Usage of git diff

Showing Differences for a Specific File or Directory

This allows you to view changes in a specific file or folder, helping you focus only on relevant modifications.

git diff file_name
OR
git diff folder_name/

**Example:

git diff app.java

gitDiff

Differences for a specific file

Showing Both Staged and Unstaged Changes

This shows all local changes by comparing your working directory and staging area with the last commit.

git diff HEAD

stage_unstaged

Staged and Unstaged Changes

Shows Difference for Staged Files

This displays changes that are staged and ready to be committed but not yet saved in history.

git diff --staged

Screenshot-2026-03-19-100711

Staged Files

Comparing Branches and Commits Using git diff

This allows you to compare changes between branches or commits to understand differences, track history, and review code before merging.

git diff

**Example:

To view differences between two specific commits, run:

git diff c5deeae 82733c3

Screenshot-2026-03-19-101019

Comparing Commits

To view differences between the master branch and feature branch, run:

git diff master feature

Screenshot-2026-03-19-101439

Comparing Branches