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

http://stackoverflow.com/questions/3580608/git-diff-does-nothing/3580631#3580631

Notes

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 foo..bar

git diff foo bar

Between last common denominator and head:

git diff foo…bar

(note extra period)

See also: http://stackoverflow.com/questions/5256249/git-diff-doesnt-show-enough/5257065#5257065

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

Leave a Reply

Your email address will not be published. Required fields are marked *