Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] git checkout -b: unparent the new branch with -o

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:48:20

Erick Mattos [off-list ref] 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.
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 <redacted>
---
[...]
quoted hunk ↗ jump to hunk
--- 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>').


+-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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help