From mboxrd@z Thu Jan 1 00:00:00 1970 From: Erick Mattos Subject: [PATCH] git checkout: create unparented branch by --orphan Date: Thu, 18 Mar 2010 13:09:39 -0300 Message-ID: <1268928579-11660-1-git-send-email-erick.mattos@gmail.com> Cc: git@vger.kernel.org, Erick Mattos To: Junio C Hamano X-From: git-owner@vger.kernel.org Thu Mar 18 17:10:26 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NsIIj-0002DF-NM for gcvg-git-2@lo.gmane.org; Thu, 18 Mar 2010 17:10:26 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532Ab0CRQKT (ORCPT ); Thu, 18 Mar 2010 12:10:19 -0400 Received: from qw-out-2122.google.com ([74.125.92.24]:29476 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000Ab0CRQKR (ORCPT ); Thu, 18 Mar 2010 12:10:17 -0400 Received: by qw-out-2122.google.com with SMTP id 8so403057qwh.37 for ; Thu, 18 Mar 2010 09:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=shuJ5b1+f2Lib+kAoTwLlWrQ8TF5F8XCWtVXy+EEIdc=; b=kT3x1ruSNPTFjXe30D4N1VDv+rmUwkJmusEmsmjNb2EBuU734nUS5GIE0hhss6PC2m Jz6klfxrFqvNYNjlB5ePSxoiO/Tfy2uuh38+y5Sf3SPB5/Ya3oHY4WE1Sj2/q5lBTAPm IGXhRC03na1mYzd0VKb+NnzMAVH2cu4bF6iD0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=bC2rIxUXX7+/4fI+pj68onDILTYa0XmfBY7HE/RryF/7mF9RWLdxbvUpPbQ4VbgfUe kyjxEkzGttdYZPP9YfKoyAJF7d9h5tiueu5qd3PLa11rAEqr4nu8NSCYN4WR1/AYvJ24 ha1sD9AjpkrAWL4FqN3jt2CrKuxdnJ0cupWAc= Received: by 10.224.83.85 with SMTP id e21mr813367qal.227.1268928615105; Thu, 18 Mar 2010 09:10:15 -0700 (PDT) Received: from localhost.localdomain ([187.15.42.217]) by mx.google.com with ESMTPS id 21sm57394qyk.13.2010.03.18.09.10.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 18 Mar 2010 09:10:14 -0700 (PDT) X-Mailer: git-send-email 1.7.0.2.280.g460a6 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Similar to -b, --orphan creates a new branch, but it starts without any commit. After running "git checkout --orphan newbranch", you are on a new branch "newbranch", and the first commit you create from this state will start a new history without any ancestry. "git checkout --orphan" keeps the index and the working tree files intact in order to make it convenient for creating a new history whose trees resemble the ones from the original branch. When creating a branch whose trees have no resemblance to the ones from the original branch, it may be easier to start work on the new branch by untracking and removing all working tree files that came from the original branch, by running a 'git rm -rf .' immediately after running "checkout --orphan". Signed-off-by: Erick Mattos --- Complete rewrite of --orphan functionality to fit it in the new design goals set by Junio. Now --orphan is not anymore an option of -b. It is an alternative to it. Junio: I ask you to reconsider only the giving of the "short-and-sweet" -o from beginning because of the new design. As it is now an alternative to -b, doing similar stuff, I think it will be nice if they look similar too. So the it will be [[-b|-o] ] not [[-b|--orphan] ]. Please ignore it if you can preview future options to checkout that could take the rest of the 21 remaining letters and 6 digits. Regards Documentation/git-checkout.txt | 21 +++++++++++++++- builtin/checkout.c | 19 +++++++++++++- t/t2017-checkout-orphan.sh | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 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..18df834 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|--orphan] ] [] 'git checkout' [-f|--ours|--theirs|-m|--conflict=