error: Can't cherry-pick into empty head
- From
- Fabrizio 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