Table of Contents

How to perform a text file diff in Git?

About

This page is about text file diff in Git

Syntax

File

git diff HEAD myFile

Branch

Between the head of the main branch and the head commit of the current branch

git diff main..HEAD --summary
# Only deleted / renamed file
git diff main..HEAD --summary | egrep '(delete|rename)'

Other diff tools

diff-index

diff-index 1) is a low level command that checks only file metadata (not the content)

Compare a tree to the working tree or index (staging area)

Example:

git diff-index --diff-filter=AM --name-only  HEAD

where: