Re: merge removed content back into current content
- From
Elijah Newren <newren@gmail.com>
- Date
- Sep 25, 2010, 23:43 UTC
- Message-ID
- <AANLkTimxHbCktv=kaq0UfV+u1kH1Pb2LYA2Xi=qkgduW@mail.gmail.com>
- In-Reply-To
- <i7jp1a$kc0$1@dough.gmane.org>
On Fri, Sep 24, 2010 at 9:06 PM, Neal Kreitzinger <neal@rsss.com> wrote:
Show 17 quoted lines
> How do I tell git to merge a single program from an old commit into the > current version of that program in the HEAD commit? In this scenario, I > want to get back some removed code but still keep the new code. > > e.g. > > Commit-1 = initial commit containing Program-A, and other programs > > Commit-2 = add Changeset-1 to Program-A , and make changes to other programs > > Commit-3 = remove Changeset-1 from Program-A, then add Changeset-2 to > Program-A, and make changes to other programs > > *desired* Commit-4 = only merge Program-A from Commit-2 into Program-A of > Commit-3, and don't change any other programs > (in other words, get my old changes from Commit-2 back, but don't loose the > new changes from Commit-3)
Does something like: git diff commit1 commit2 -- ProgramA | git apply do what you need?
If diff+apply doesn't work[1], you can try git cat-file -p commit1:ProgramA > base git cat-file -p commit2:ProgramA > other git cat-file -p commit3:ProgramA > current git merge-file current base other
[1] e.g. would cause conflicts -- btw, does anyone know how to force git apply to proceed and add conflict markers if necessary rather than just bailing out?