git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: Ani Sinha <ani@anirban.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Cherry pick a commit but with files in another location
Date: Sat, 11 Apr 2020 14:21:11 +0200	[thread overview]
Message-ID: <CAN0heSrFFABmtitJHu1tVw03oRCs63=UiSknmoZr60NT9dR9Fg@mail.gmail.com> (raw)
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:
>
> 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

  reply	other threads:[~2020-04-11 12:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 11:21 Cherry pick a commit but with files in another location Ani Sinha
2020-04-11 12:21 ` Martin Ågren [this message]
     [not found]   ` <b26f041f-82d5-450f-998d-5a5c557a7994@Spark>
2020-04-11 12:42     ` Martin Ågren
2020-04-11 13:25       ` Ani Sinha
2020-04-13  5:43         ` Martin Ågren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN0heSrFFABmtitJHu1tVw03oRCs63=UiSknmoZr60NT9dR9Fg@mail.gmail.com' \
    --to=martin.agren@gmail.com \
    --cc=ani@anirban.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).