From: Erick Mattos Date: Tue, 23 Feb 2010 21:20:07 GMT Subject: [PATCH] git checkout -b: unparent the new branch with -o Message-ID: <1266960007-16127-1-git-send-email-erick.mattos@gmail.com> 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. The new -o/--orphan is intended to solve this situation allowing the creation of a new branch unparented to any other. 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. Signed-off-by: Erick Mattos --- This new option just make it easy to add orphan branches to git repositories. There are a lot of hacks to do the same thing ( I had been using some! :-) ) but this should be seen as a part of a normal work flow so just an option. A good example to show the need of this option is a Debian folder of control files. Whenever a maintainer needs to debianize a source code to build packages he needs to add a folder called Debian with a lot of files inside it. Those files are connected to the source code of the program but they are not really part of the program development. On this situation using the new option, that maintainer would do: git checkout -ob debian git clean -df mkdir Debian add all control files ...hack it enough... git add Debian git commit And then when ready to build the packages from the master branch he would just need to merge or cherry-pick the Debian branch on it. On this work flow both developments occur paralleled and fuse only at the moment of building the Debian's packages. I have some other examples to tell but I think you people already have figured the needs and possible uses out. :-) Kind regards builtin-checkout.c | 14 +++++++++- t/t2017-checkout-orphan.sh | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100755 t/t2017-checkout-orphan.sh diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 37c1810..6534934 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git checkout' [-q] [-f] [-m] [] -'git checkout' [-q] [-f] [-m] [-b ] [] +'git checkout' [-q] [-f] [-m] [-b [-o]] [] 'git checkout' [-f|--ours|--theirs|-m|--conflict=