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

error: Can't cherry-pick into empty head

From
FCFabrizio Cucci <fabrizio.cucci@gmail.com>
Date
May 28, 2016, 17:54 UTC
Message-ID
<CAOxYW4yTCMYcY=9YvwHNK5rKDK0_f-Uc7L92-QuQkv_hwCV+HA@mail.gmail.com>
Hello everyone,
I'm trying to understand why I'm getting the error as per subject.

The scenario is the following: I'm on the master branch (which contains several commits) and I would like to create a new empty branch (let's call it new-orphan) and cherry-pick only the commits related to a specific folder (let's call it my-folder) from the master branch.

So, I tried the following command sequence:
  master $ git checkout --orphan new-orphan
  new-orphan $ git rm --cached -r .
  new-orphan $ git clean -df
After confirming that I'm in a clean state (with "$ git status") I tried:
  new-orphan $ git rev-list --reverse master -- my-folder/ | git
cherry-pick --stdin

as suggested https://git-scm.com/docs/git-cherry-pick, but what I get is "error: Can't cherry-pick into empty head".

What I don't really understand is:
1) if I cherry-pick a single commit instead of multiple commits,
everything works fine:
  new-orphan $ git cherry-pick <some-commit-id>
2) if I commit something before trying the above command, everything works fine:
  new-orphan $ touch README
  new-orphan $ git add README
  new-orphan $ git commit -m "added README"
  new-orphan $ git rev-list --reverse master -- my-folder/ | git
cherry-pick --stdin
Can someone please help me understand this?

Thanks, Fabrizio

Next: Michael J Gruber
Message 1 of 7 in “error: Can't cherry-pick into empty head”
  1. Fabrizio CucciMay 28, 2016
  2. Michael J GruberJun 6, 2016
  3. cherry-pick: allow to pick to unborn branchesMichael J Gruber, Jun 6, 2016
  4. Torsten BögershausenJun 6, 2016
  5. Junio C HamanoJun 6, 2016
  6. Michael J GruberJun 7, 2016
  7. Junio C HamanoJun 7, 2016

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.