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

Re: Cherry pick a commit but with files in another location

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Apr 11, 2020, 12:42 UTC
Message-ID
<CAN0heSodSeT=Sj4pnutFPgbu9jjwQ_JBtBee1iyP=D3Oc_5G=g@mail.gmail.com>
In-Reply-To
<b26f041f-82d5-450f-998d-5a5c557a7994@Spark>
Hi,
On Sat, 11 Apr 2020 at 14:24, Ani Sinha <ani@anirban.org> wrote:
Show 20 quoted lines
> On Apr 11, 2020, 17:51 +0530, Martin Ågren <martin.agren@gmail.com>, wrote:
>
> > On Sat, 11 Apr 2020 at 13:33, Ani Sinha <ani@anirban.org> wrote:
>
> > > 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
...
> > git mv olddir newdir
...
> > What kind of conflicts do you get in your real-world use case?
> My usecase is slightly different. The files I want to patch has been
> moved under a new subdirectory which is under the original root
> directory. So in order to patch, I need to add a new prefix to the patch
> manually.

I'm not able to fully guess your situation from this, but I wonder about one thing: Do you use "git cherry-pick", "git am" or "git apply"? (Or something else entirely?) Are you aware of "-p<n>" for "git apply" (and "--directory=<root>"?) and are wondering what similar options are available with "git cherry-pick"?

I still don't fully understand what you're doing and what you're seeing, so it's hard to get a good picture of the problem.

I'm about to leave, so if I stay silent for several hours, that's why. :)
Martin
Previous: Martin ÅgrenNext: Ani Sinha
Message 3 of 5 in “Cherry pick a commit but with files in another location”
  1. Ani SinhaApr 11, 2020
  2. Martin ÅgrenApr 11, 2020
  3. Martin ÅgrenApr 11, 2020
  4. Ani SinhaApr 11, 2020
  5. Martin ÅgrenApr 13, 2020

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.