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

Re: [PATCH 2/2] learn to pick/revert into unborn branch

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 23, 2012, 03:24 UTC
Message-ID
<7vr4mhpi0l.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1356117013-20613-2-git-send-email-martinvonz@gmail.com>
Martin von Zweigbergk <martinvonz@gmail.com> writes:
>>From the user's point of view, it seems natural to think that
> cherry-picking into an unborn branch should work, so make it work,
> with or without --ff.

I actually am having a hard time imagining how that could ever be natural.

When you are on an unborn branch, you may have some files in your working tree, and some of them may even be registered to the index, but the index is merely for your convenience to create your first commit, and as far as the history is concered, it does not matter.

By definition you do not have any history in such a state. What does it even mean to "cherry-pick" another commit, especially without the --no-commit option? The resulting commit will carry the message taken from the original commit, but does what it says match what you have done?

I can understand that it may sometimes make sense to do
  $ git show --diff-filter=A $that_commit | git apply

as a way to further update the uncommitted state you have in the working tree, so I can sort of buy that --no-commit case might make some sense (but if you make a commit after "cherry-pick --no-commit", you still get the log message from that commit, which does not explain the other things you have in your working tree) in a limited situation.

It seems to me that the only case that may make sense is to grab the contents from an existing tree, which might be better served with

  $ git checkout $that_commit -- $these_paths_I_am_interested_in
> Cherry-picking anything other than a commit that only adds files, will
> naturally result in conflicts. Similarly, revert also works, but will
> result in conflicts unless the specified revision only deletes files.

You may be able to make it "work" for some definition of "work", but I am not sure how useful it is.

Puzzled...
Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 3 of 11 in “tests: move test_cmp_rev to test-lib-functions”
  1. 1/2 tests: move test_cmp_rev to test-lib-functionsMartin von Zweigbergk, Dec 21, 2012
  2. 2/2 learn to pick/revert into unborn branchMartin von Zweigbergk, Dec 21, 2012
  3. Junio C HamanoDec 23, 2012
  4. Martin von ZweigbergkDec 23, 2012
  5. Christian CouderDec 23, 2012
  6. Junio C HamanoDec 23, 2012
  7. Philip OakleyDec 23, 2012
  8. Junio C HamanoDec 23, 2012
  9. Junio C HamanoDec 23, 2012
  10. Martin von ZweigbergkDec 24, 2012
  11. Junio C HamanoDec 23, 2012

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.