git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to apply patch in the middle

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 15, 2009, 01:39 UTC
Message-ID
<20090115013913.GC10179@spearce.org>
In-Reply-To
<20090115013535.GB6937@b2j>
bill lam <cbill.lam@gmail.com> wrote:
Show 7 quoted lines
> I want to change history to rewrite
> 
>   - A - B - C - D - E - ..
>  
> as
> 
>  - A - C' - D - E - ..

Uh, "git rebase -i A", change "pick" on line "C" to "squash". This should have the same impact as what you are trying.

Show 6 quoted lines
> because rebase/squash cannot automatically resolve conflicts, I
> generate a patch file from A to C
> 
>   git diff A C >pat
> 
> However I don't know how apply this patch and cancel the old B and C.
One way you can insert this is:
  git rebase -i A^
  change "pick" on line "A" to "edit"
  delete lines "B" and "C".
  when it stops for amend, don't amend.
  git apply --index pat
  git commit -m "my new B and C"
  git rebase --continue
-- 
Shawn.
Previous: bill lam
Message 2 of 2 in “how to apply patch in the middle”
  1. bill lamJan 15, 2009
  2. Shawn O. PearceJan 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.