git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Jeff King <peff@peff.net>,
	"Robert P. J. Day" <rpjday@crashcourse.ca>,
	Git Mailing list <git@vger.kernel.org>
Subject: Re: how to most effectively cherry pick by selective patch hunk?
Date: Wed, 10 Feb 2021 16:54:15 -0800	[thread overview]
Message-ID: <CABPp-BGKvsqQ3Xn_7Xi0GqxKS5qSdN6WyLYUXWWtzwdPqT_zTQ@mail.gmail.com> (raw)
In-Reply-To: <87im712mi7.fsf@igel.home>

On Tue, Feb 9, 2021 at 11:44 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Feb 09 2021, Jeff King wrote:
>
> > Of course that involves a change to Git, and you were looking for
> > something you could do with existing versions. :) You can emulate it by
> > making the commit's parent equivalent to your current state. I.e.:
> >
> >   git checkout --detach ;# detached HEAD for temporary commit
> >   git cherry-pick $commit ;# maybe deal with conflicts
> >   commit=$(git rev-parse --verify HEAD) ;# remember the temp commit
> >   git checkout - ;# back to your branch
> >   git checkout -p $commit
>
> Alternatively, you could cherry-pick normally, then use
>  git checkout -p HEAD^
> to remove what you don't want.

Or, going into the slightly esoteric, you could define a custom local
merge driver for the particular file you want to ignore and say that
merges of that file always use the original version and ignore changes
made on both sides.

man gitattributes(5), search for "filfre"

Appears to be unchanged since git-2.5.0.

Only ever used them once myself long ago (and not for a real usecase),
because I wanted to understand what they were for.  However, it seems
like they might be useful here.

      reply	other threads:[~2021-02-11  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 13:58 how to most effectively cherry pick by selective patch hunk? Robert P. J. Day
2021-02-09 16:39 ` Jeff King
2021-02-09 16:58   ` Robert P. J. Day
2021-02-09 17:12   ` Andreas Schwab
2021-02-11  0:54     ` Elijah Newren [this message]

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=CABPp-BGKvsqQ3Xn_7Xi0GqxKS5qSdN6WyLYUXWWtzwdPqT_zTQ@mail.gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=rpjday@crashcourse.ca \
    --cc=schwab@linux-m68k.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).