How to perform a text file diff in Git?


This page is about text file diff in Git



git diff HEAD myFile


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 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)


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


  • diff-filter filters is a sequence of short status
  • name-only prints only the name

Discover More
Git - difftool

This article is the difftool configuration. Is there a diff with the mergetool? meld on linux WinMerge or p4merge on windows git difftool --tool= may be set to one of the following:...
What are short status ?

short status is a one letter that summarize the file status Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …)...

Share this page:
Follow us:
Task Runner