git: differences between files and branches

Basic usage

$ git diff            (1)

$ git diff –cached   (2)

$ git diff HEAD       (3)

1. Diff the working copy with the index

2. Diff the index with HEAD

3. Diff the working copy with HEAD


git diff A B

only shows difference between states of the tree between exactly two points in the commit graph. Doesn’t care about history.

Between head:

git diff

git diff foo bar

Between last common denominator and head:

git diff foo…bar

(note extra period)

See also:

Difference between branches

git diff –name-status master..branch

Difference between 2 files on separate branches

git diff BranchA:ai.rb BranchB:ai.rb

Differences between files in working copy and branch

git diff foo master:foo

Automatic Post Tagger

Not quite as awesome as an automatic post categoriser but still pretty handy: