{"thread":{"id":"17187","subject":"how to apply patch in the middle","startedAt":"2009-01-15T01:35:35Z","lastAt":"2009-01-15T01:39:13Z","messageCount":2,"participants":["bill lam","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"100531","messageId":"20090115013535.GB6937@b2j","threadId":"17187","inReplyTo":null,"subject":"how to apply patch in the middle","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-15T01:35:35Z","receivedAt":"2009-01-15T01:35:35Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"I want to change history to rewrite\n\n  - A - B - C - D - E - ..\n \nas\n\n - A - C' - D - E - ..\n\nbecause rebase/squash cannot automatically resolve conflicts, I\ngenerate a patch file from A to C\n\n  git diff A C >pat\n\nHowever I don't know how apply this patch and cancel the old B and C.\nSorry for this newbie question.\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩008 杜甫  望嶽\n    岱宗夫如何  齊魯青未了  造化鍾神秀  陰陽割昏曉\n    盪胸生層雲  決眥入歸鳥  會當凌絕頂  一覽眾山小\n"},{"id":"100533","messageId":"20090115013913.GC10179@spearce.org","threadId":"17187","inReplyTo":"20090115013535.GB6937@b2j","subject":"Re: how to apply patch in the middle","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-01-15T01:39:13Z","receivedAt":"2009-01-15T01:39:13Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"bill lam <cbill.lam@gmail.com> wrote:\n> I want to change history to rewrite\n> \n>   - A - B - C - D - E - ..\n>  \n> as\n> \n>  - A - C' - D - E - ..\n\nUh, \"git rebase -i A\", change \"pick\" on line \"C\" to \"squash\".\nThis should have the same impact as what you are trying.\n\n> because rebase/squash cannot automatically resolve conflicts, I\n> generate a patch file from A to C\n> \n>   git diff A C >pat\n> \n> However I don't know how apply this patch and cancel the old B and C.\n\nOne way you can insert this is:\n\n  git rebase -i A^\n  change \"pick\" on line \"A\" to \"edit\"\n  delete lines \"B\" and \"C\".\n\n  when it stops for amend, don't amend.\n  git apply --index pat\n  git commit -m \"my new B and C\"\n  git rebase --continue\n\n-- \nShawn.\n"}]}