1

I have two branches A, and B. (they're both remote branches too). Is there a way to do a diff of a single file between the two branches? It's located in the same place in both branches etc.

lucapette
  • 20,564
  • 6
  • 65
  • 59
user291701
  • 38,411
  • 72
  • 187
  • 285
  • possible duplicate of [Unable to diff files in two separate branches in Git](http://stackoverflow.com/questions/916822/unable-to-diff-files-in-two-separate-branches-in-git) – Brian Roach Feb 17 '12 at 17:14
  • And [this is an answer](http://stackoverflow.com/a/916914/960558) – Lazy Badger Feb 17 '12 at 17:39
  • @LazyBadger: It may be an answer but it's not a *good* answer. There's no reason to specify the filename twice. – Cascabel Feb 17 '12 at 18:07
  • @Jefromi - in original question it's a must due to rename – Lazy Badger Feb 17 '12 at 18:21
  • Sure. That doesn't make it useful for this question, though. (And I'm sure there's a duplicate question here somewhere, but I do not think that one's a good candidate. That poster wants to use a difftool.) – Cascabel Feb 17 '12 at 18:34

2 Answers2

4

I use git diff branch1 branch2 -- <File1>[, <File2>...] to achieve this.

ksol
  • 11,835
  • 5
  • 37
  • 64
-1
git diff A:File..B:File

Git Reference (abot git diff), Git Community Book, "git - compare branches" for details

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110