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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ani,

On Sat, 11 Apr 2020 at 13:33, Ani Sinha <ani@xxxxxxxxxxx> 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
  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux