Re: Cherry pick a commit but with files in another location
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Apr 11, 2020, 12:21 UTC
- Message-ID
- <CAN0heSrFFABmtitJHu1tVw03oRCs63=UiSknmoZr60NT9dR9Fg@mail.gmail.com>
- In-Reply-To
- <FC3905FB-D3B9-433D-876D-8DB68D3491C3@anirban.org>
Hi Ani,
On Sat, 11 Apr 2020 at 13:33, Ani Sinha <ani@anirban.org> wrote:
Show 7 quoted lines
> > I have an use case where I need to cherry pick a change from one branch > to another. The change will apply cleanly but the files in the branch > where I want to cherry pick the co mit to have been moved under a > different directory. So simple cherry pick will result in conflicts. Is > there a clean way to cherry pick in this case? Is there an option to > provide -p0, -p1 etc to the patch?
I just tried the following commands. Admittedly, this example is a bit silly, but at least for me, Git does handle the move just fine. Does this work for you?
mkdir test cd test git init mkdir olddir echo old >olddir/file git add olddir/ git commit -m Initial git mv olddir newdir git commit -m Move echo new >newdir/file git commit newdir/file -m Change git checkout -b my-branch HEAD~2 # pre-move git cherry-pick master cat olddir/file
What kind of conflicts do you get in your real-world use case?
Martin