Re: [PATCH] Docs: git checkout --orphan: `root commit' and `branch head'
- From
Jay Soffian <jaysoffian@gmail.com>
- Date
- Sep 28, 2011, 04:04 UTC
- Message-ID
- <CAG+J_DxzcuYiffm6XVX-RQSxeMwy4Yi7CdhCdddAN=xRyJ2b5Q@mail.gmail.com>
- In-Reply-To
- <7v39fhyk21.fsf@alter.siamese.dyndns.org>
On Tue, Sep 27, 2011 at 1:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Michael Witten <mfwitten@gmail.com> writes: > >> It seems like a more logical approach would be instead for "git >> commit" to take a "--root" option that would create a new root commit >> based on the current index and then point the current branch head to >> the new root commit. Thus: >> >> $ git checkout -b new_branch old_branch >> $ # Manipulate or not >> $ git commit --root >> >> That's how people think. > > This may indeed be an improvement. I suspect that we'd need to think about > it a bit more, but it feels right (perhaps introduce this new option, > deprecate --orphan from the checkout, and then eventually remove it > sometime in 1.8.0 timeframe).
Hrm, create new_branch just so you can immediately clobber its SHA1 with the new commit that has no parents. That doesn't seem quite right. Imagine you use "git commit --root" by accident while on master, then you have to dig into your reflog?
But it's close. Maybe:
$ git commit --new-root-branch=<name>
Which creates <name> with the index as its sole commit and switches you to that branch? That doesn't feel quite right either.
</thinking out loud>
j.