threads / discuss / 23020

FEATURE REQUEST: Cherry pick in not checked out branch

Subject: FEATURE REQUEST: Cherry pick in not checked out branch

## tl;dr

6 messages between Mar 15, 2010 and Mar 15, 2010.

replies: 5people: 5as markdown or json

Maxim Treskin· Mar 15, 2010, 08:39 UTC · lore
Hello

git cherry-pick applies the change introduced by specified commit only to currently checked out branch. Why this requirement exists? Is it possible to apply changes to not checked out branch, like:

$ git cherry-pick <branch> <commit>
Thank you
-- 
Maxim Treskin
Tim Mazid· Mar 15, 2010, 08:55 UTC · re: Maxim Treskin · lore

RE: FEATURE REQUEST: Cherry pick in not checked out branch

That's actually a very good point. I could have used such a feature on a number of occasions. I second this feature request.

Show 21 quoted lines
> Date: Mon, 15 Mar 2010 14:39:38 +0600
> Subject: FEATURE REQUEST: Cherry pick in not checked out branch
> From: zerthurd@gmail.com
> To: git@vger.kernel.org
> 
> Hello
> 
> git cherry-pick applies the change introduced by specified commit only
> to currently checked out branch. Why this requirement exists? Is it
> possible to apply changes to not checked out branch, like:
> 
> $ git cherry-pick <branch> <commit>
> 
> Thank you
> 
> -- 
> Maxim Treskin
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
 		 	   		  
_________________________________________________________________
Link all your email accounts and social updates with Hotmail. Find out now.
http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G
Sverre Rabbelier· Mar 15, 2010, 09:43 UTC · re: Maxim Treskin · lore

Re: FEATURE REQUEST: Cherry pick in not checked out branch

Heya,
On Mon, Mar 15, 2010 at 09:39, Maxim Treskin <zerthurd@gmail.com> wrote:
> git cherry-pick applies the change introduced by specified commit only
> to currently checked out branch. Why this requirement exists? Is it
> possible to apply changes to not checked out branch, like:
Because you need a working directory to resolve conflicts.
-- 
Cheers,

Sverre Rabbelier
Tim Mazid· Mar 15, 2010, 09:54 UTC · re: Sverre Rabbelier · lore

RE: FEATURE REQUEST: Cherry pick in not checked out branch

Hi,
 
Could we not make cherry-pick "stash, checkout, cherry-pick, checkout, pop"?
 
Cheers,
Tim.
----------------------------------------
Show 23 quoted lines
> From: srabbelier@gmail.com
> Date: Mon, 15 Mar 2010 10:43:14 +0100
> Subject: Re: FEATURE REQUEST: Cherry pick in not checked out branch
> To: zerthurd@gmail.com
> CC: git@vger.kernel.org
>
> Heya,
>
> On Mon, Mar 15, 2010 at 09:39, Maxim Treskin  wrote:
>> git cherry-pick applies the change introduced by specified commit only
>> to currently checked out branch. Why this requirement exists? Is it
>> possible to apply changes to not checked out branch, like:
>
> Because you need a working directory to resolve conflicts.
>
> --
> Cheers,
>
> Sverre Rabbelier
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
 		 	   		  
_________________________________________________________________
Looking for a new home? With all the latest places, searching has never been easier.
http://clk.atdmt.com/NMN/go/157631292/direct/01/
Michael J Gruber· Mar 15, 2010, 11:01 UTC · re: Tim Mazid · lore

Re: FEATURE REQUEST: Cherry pick in not checked out branch

Tim Mazid venit, vidit, dixit 15.03.2010 10:54:
> 
> Hi,
>  
> Could we not make cherry-pick "stash, checkout, cherry-pick, checkout, pop"?
Sure, that would be 5 command invocations requiring a work tree ;)

Seriously, you can make this into an alias or custom commend, of course, but it would possibly need to stop in a state of conflict, the very same way that rebase -i may. There are structural improvements on the way which will make rebase -i, cherry-pick and so on use the same underlying code base, and that will help implementing requests such as this one.

Michael

P.S.: Please don't top-post (I cut it). P.P.S.: Please don't cull cc (I re-added SR).

Johannes Schindelin· Mar 15, 2010, 13:12 UTC · re: Michael J Gruber · lore

Re: FEATURE REQUEST: Cherry pick in not checked out branch

Hi,
On Mon, 15 Mar 2010, Michael J Gruber wrote:
Show 6 quoted lines
> Tim Mazid venit, vidit, dixit 15.03.2010 10:54:
> 
> > Could we not make cherry-pick "stash, checkout, cherry-pick, checkout, 
> > pop"?
> 
> Sure, that would be 5 command invocations requiring a work tree ;)

Actually, if you want something that does not change all the timestamps, and that does only trivial merges (i.e. no conflicts), you may have luck with something like this:

	test $# = 2 || {
		echo "Usage: $0 <commit> <branch>" >&2
		exit 1
	}
	GIT_INDEX_FILE=.git/tmp.index &&
	export GIT_INDEX_FILE &&
	git read-tree "$2" &&
	git diff "$1"^! | git apply --index &&
	tree=$(git write-tree) &&
	msg="$(git cat-file commit "$1" | sed '1,/^$/d')" &&
	commit=$(echo "$msg" | git commit-tree $tree -p "$2") &&
	git update-ref -m cherry-pick-2.0 "$2" $commit

Totally Untested(tm), Dscho

← back to recent threads