ZANARDI Bruno

Software Developper

About
Resume

Git Blog

Git command `diff`

Definition

Show changes between commits, commit and working tree, etc.

Basic usage

Compare file

$ git diff <file>            # between working dir and index
$ git diff --cached <file>   # between index and last commit
$ git diff HEAD <file>       # between working dir and las commit

Compare commits

$ git diff <hash_1>..<hash_2>

Compare directories

$ git diff            # working dir v. index
$ git diff --cached   # index v. last commit
$ git diff HEAD       # working dir v. last index

Show only changes statistics

$ git diff --stat