Re: Common ancestor in merge diffs?
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Jan 26, 2009, 19:05 UTC
- Message-ID
- <alpine.LFD.2.00.0901261100200.5284@localhost.localdomain>
- In-Reply-To
- <alpine.LNX.1.00.0901261318030.19665@iabervon.org>
On Mon, 26 Jan 2009, Daniel Barkalow wrote:
Show 8 quoted lines
> > I was just doing an annoying merge (I'd reorganized code while other > people made changes to it), and I kept having the problem that it was hard > to figure out what each side had done. Is there some way to ask git for > the diffs between the common ancestor (which is unique in my case, so it's > actually useful) and each of the sides of the merge? Ideally, it would > give essentially the converse of the --cc diff: first column is -stage 1 > +stage 2; second column is -stage 1 +stage 3.
Have you tried "gitk --merge [filename]"?
That's usually even more useful - because it doesn't just give a diff, it gives the actual commits that caused the conflict. That way you see what both sides of a merge tried to do.. It's what I do when encountering conflicts on the kernel (where I'm usually not the author of _either_ side of the code that causes a conflict), and it really is very powerful.
That said, finding the diffs from the common case is pretty trivial too. Just do
git diff MERGE_HEAD...HEAD [filename]
and you'll get the diff from the common case to the HEAD, and if you switch them around, you'll get the diff from the common commit to the MERGE_HEAD. Note the _three_ dots.
Linus