# two git-cherry-pick enhancements

4 messages from 2008-05-21 to 2008-05-22. Participants: Nico -telmich- Schottelius, Govind Salinas, Sitaram Chamarty, Johannes Schindelin.
Thread: https://gitlist.dev/t/13602

## Nico -telmich- Schottelius, 2008-05-21 16:38

Subject: two git-cherry-pick enhancements
Message-ID: <20080521163817.GA13124@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080521163817.GA13124%40denkbrett.schottelius.org

```
Hello!

When using git-cherry-pick there are two things missing for me and just
wondered how you see it (or maybe have a good solution):

- Apply only parts of the patch which applies to <file ...>:
   I sometimes want to apply patches only to some, but not all
   files the patch introduces

- Interactively selecting which parts to apply:
   I want only 7 out of 10 changes the patch introduces.
   It would help alot, if I could choose which parts I want
   to apply for every part of the patch.

Anything planned like that or did I oversee the right way?

Sincerly

Nico

P.S.: Please CC me on reply, I am not subscribed.

-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C

```

## Govind Salinas, 2008-05-21 18:36

Subject: Re: two git-cherry-pick enhancements
Message-ID: <5d46db230805211136k7bf81bc0t9610fe2bb50a08b9@mail.gmail.com>
URL: https://gitlist.dev/e/5d46db230805211136k7bf81bc0t9610fe2bb50a08b9%40mail.gmail.com
In-Reply-To: <20080521163817.GA13124@denkbrett.schottelius.org>

```
On Wed, May 21, 2008 at 11:38 AM, Nico -telmich- Schottelius
<nico-git-20080521@schottelius.org> wrote:
> Hello!
>
> When using git-cherry-pick there are two things missing for me and just
> wondered how you see it (or maybe have a good solution):
>
> - Apply only parts of the patch which applies to <file ...>:
>   I sometimes want to apply patches only to some, but not all
>   files the patch introduces
>
> - Interactively selecting which parts to apply:
>   I want only 7 out of 10 changes the patch introduces.
>   It would help alot, if I could choose which parts I want
>   to apply for every part of the patch.
>
> Anything planned like that or did I oversee the right way?
>
> Sincerly
>
> Nico
>
> P.S.: Please CC me on reply, I am not subscribed.
>

You could "git cherry-pick --no-commit <id>" and then "git add -p"

-Govind

```

## Sitaram Chamarty, 2008-05-22 08:58

Subject: Re: two git-cherry-pick enhancements
Message-ID: <2e24e5b90805220158n5c31da1yf98cac8b432a2d9d@mail.gmail.com>
URL: https://gitlist.dev/e/2e24e5b90805220158n5c31da1yf98cac8b432a2d9d%40mail.gmail.com
In-Reply-To: <20080521163817.GA13124@denkbrett.schottelius.org>

```
On Wed, May 21, 2008 at 10:08 PM, Nico -telmich- Schottelius
<nico-git-20080521@schottelius.org> wrote:
> - Apply only parts of the patch which applies to <file ...>:
>   I sometimes want to apply patches only to some, but not all
>   files the patch introduces
>
> - Interactively selecting which parts to apply:
>   I want only 7 out of 10 changes the patch introduces.
>   It would help alot, if I could choose which parts I want
>   to apply for every part of the patch.

Both of these are (often, though not always) signs that commits are
not granular enough.  Your branch maintainer or developer has combined
unrelated things into one commit.  In an ideal world, he would put
each piece as a separate commit, such that if you pick one of those
apart, it doesn't make sense.

This is also usually a sign of someone using a central VCS model (or
mental model) on that side.

Unless you have no control over who sends you these commits, you may
want to address that also in whatever way possible.

IMO stuff like "git add -a" (and the GUI equivalents) were meant for
your own development, so that you can essentially re-write history in
a sane sequence after having worked on a complex task.

Regards,

Sitaram

```

## Johannes Schindelin, 2008-05-22 09:29

Subject: Re: two git-cherry-pick enhancements
Message-ID: <alpine.DEB.1.00.0805221026140.30431@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0805221026140.30431%40racer
In-Reply-To: <20080521163817.GA13124@denkbrett.schottelius.org>

```
Hi,

On Wed, 21 May 2008, Nico -telmich- Schottelius wrote:

> When using git-cherry-pick there are two things missing for me and just 
> wondered how you see it (or maybe have a good solution):
> 
> - Apply only parts of the patch which applies to <file ...>:
>    I sometimes want to apply patches only to some, but not all
>    files the patch introduces
> 
> - Interactively selecting which parts to apply:
>    I want only 7 out of 10 changes the patch introduces.
>    It would help alot, if I could choose which parts I want
>    to apply for every part of the patch.
> 
> Anything planned like that or did I oversee the right way?

Conceptually, this is really not cherry-picking _commits_.  For example, 
the commit message will typically be all wrong if you pick only one 
change.  Also, if I were the author of the original patch, I would not be 
happy for you to label me author of the cut-down (and possibly invalid) 
commit.

Therefore I suggest (just like on IRC the other day):

	git show <commit> -- <file(s)> | git apply

possibly followed by

	git add -i

or

	git add -p <file>

Hth,
Dscho

```
