Matt V.
Matt V.

Reputation: 9809

How to git diff from an earlier version without some of the intermediate additions?

I'm working on an addition to a project that is loosely based on another patch to the same project. I started by cloning the repository (A). I then applied the patch I wanted use as "inspiration" for my additions (B). I made a branch in preparation for my changes (C) and then added the new code (D).

A-----B
       \
        \
         C-----D

I want my new additions to be separate from the "inspiration" patch. How can I now generate a patch file (ie, git diff) that does not include the "inspiration" patch (B or C)? The patches will each essentially represent a plugin with a unique use case, so the process for getting each rolled into the project will be different.

Upvotes: 0

Views: 59

Answers (2)

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49028

You need to rebase your change to be based on A instead of C.

git rebase --onto A C

Upvotes: 2

Carl Norum
Carl Norum

Reputation: 224884

If D doesn't depend on B or C, you should just be able to generate a patch from C->D and get exactly what you want:

git format-patch C..D

Upvotes: 1

Related Questions