Re: error: Can't cherry-pick into empty head
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Jun 6, 2016, 13:21 UTC
- Message-ID
- <afafa51c-f950-594e-7142-5b28b1182add@drmicha.warpmail.net>
- In-Reply-To
- <CAOxYW4yTCMYcY=9YvwHNK5rKDK0_f-Uc7L92-QuQkv_hwCV+HA@mail.gmail.com>
Fabrizio Cucci venit, vidit, dixit 28.05.2016 19:54:
Show 40 quoted lines
> 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?
The implementation for the single commit and multiple commit cases is different (so that you can do a single cherry-pick from with a running cherry-pick sequence). As a side effect, the single commit pick does not care about an empty head.
I'll follow up with a patch which changes that.
Michael