Re: [PATCH] git checkout -b: unparent the new branch with -o
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Feb 23, 2010, 23:26 UTC
- Message-ID
- <m3ocjfmt60.fsf@localhost.localdomain>
- In-Reply-To
- <1266960007-16127-1-git-send-email-erick.mattos@gmail.com>
Erick Mattos <erick.mattos@gmail.com> writes:
> Subject: [PATCH] git checkout -b: unparent the new branch with -o
I would say it is rather: "git checkout -b: allow creating unrelated branch", or something like that.
By the way, for the solution to be complete it should work not only for "git checkout -b" shortcut, but also for "git branch".
> > Sometimes it is necessary to start up a new development branch of code > intended to be merged in the near future to existing branches but which > actually does not relate to them.
I'm not sure if 'unrelated but _intended to merge_' is most common workflow utilizing unrelated branches... and whether git should promote such workflow, even if only describing it in the commit message.
> > The new -o/--orphan is intended to solve this situation allowing the > creation of a new branch unparented to any other.
I think that for example '--root', or '--rootless', or '--unrelated' would be a better name than '--orphan'. Besides I don't think that such rarely used option should squat on rare resource of single-letter option.
Show 5 quoted lines
> > After the 'checkout -o -b' the new branch is not saved until some files are > added to the index and committed, exactly as if it was an initial commit. > A 'git clean -df' would delete everything from the work tree making it > empty for new files.
Does it mean that the index is empty, but the working area is unchanged? It is not clear from the commit message.
> > Signed-off-by: Erick Mattos <erick.mattos@gmail.com> > ---
[...]
Show 8 quoted lines
> --- a/Documentation/git-checkout.txt > +++ b/Documentation/git-checkout.txt > @@ -9,7 +9,7 @@ SYNOPSIS > -------- > [verse] > 'git checkout' [-q] [-f] [-m] [<branch>] > -'git checkout' [-q] [-f] [-m] [-b <new_branch>] [<start_point>] > +'git checkout' [-q] [-f] [-m] [-b <new_branch> [-o]] [<start_point>]
This is not stricly correct, as you can use either '-o' OR '<start_point>', but not both (but you can use '-o' only together with '-b <new_branch>').
Show 5 quoted lines
> +-o:: > +--orphan:: > + When creating a new branch, set it up as unparented thus > + unrelated to the previous branch. > +
Unparented? Perhaps "set it up so first commit on this branch would be root (parenless) commit". Hmmm... it is not easy to describe it well...
-- Jakub Narebski Poland ShadeHawk on #git