Patricio Treviño

Patricio Treviño

Husband . Father . Developer

Get the delta between two git branches

facebook sharing button
twitter sharing button
linkedin sharing button
reddit sharing button
digg sharing button
tumblr sharing button
whatsapp sharing button
email sharing button
print sharing button

Syntax

git diff [options] <commit>[..<commit>] [--] [<path>...]
view raw syntax.text hosted with ❤ by GitHub

Option Description
options The differen options that can be used to report the differences
commit An arbitrary commit/branch to be compared.
commit The second commit/branch to be compared, if omitted then HEAD (of the current branch) is used.
path... If path is specified, then the comparison happens at the file level instead of commit/branch level.

Note: common options are
--minimal, spend extra time to make sure the smallest possible diff is produced.
--summary, output a condensed summary of extended header information such as creations, renames and mode changes.
--name-only, show only names of changed files.
--name-status, show only names and status of changed files.
--diff-filter, select only files that are:
Added (A) Copied (C) Deleted (D) Modified (M) Renamed (R) Changed (T) Unmerged (U) Unknown (X) airing Broken (B)

Example

# get delta between HEAD and origin/master displaying status and name of the files
git diff --name-status origin/master
# get delta between HEAd and origin/master displaying status and name of the files and showing only added files
git diff --name-status --diff-filter A origin/master
view raw example.sh hosted with ❤ by GitHub

References

git-diff