git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 15, 2010, 13:12 UTC
Message-ID
<alpine.DEB.1.00.1003151359440.7596@pacific.mpi-cbg.de>
In-Reply-To
<4B9E13A4.3090502@drmicha.warpmail.net>
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

Previous: Michael J Gruber
Message 6 of 6 in “FEATURE REQUEST: Cherry pick in not checked out branch”
  1. Maxim TreskinMar 15, 2010
  2. Tim MazidMar 15, 2010
  3. Sverre RabbelierMar 15, 2010
  4. Tim MazidMar 15, 2010
  5. Michael J GruberMar 15, 2010
  6. Johannes SchindelinMar 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.