From: Erick Mattos Subject: [PATCH v2] git checkout: create unparented branch by --orphan Date: Sat, 20 Mar 2010 17:05:11 -0300 Message-ID: <1269115511-21804-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 Sat Mar 20 21:06:34 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 1Nt4wI-000564-80 for gcvg-git-2@lo.gmane.org; Sat, 20 Mar 2010 21:06:30 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751470Ab0CTUGX (ORCPT ); Sat, 20 Mar 2010 16:06:23 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:32950 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305Ab0CTUGW (ORCPT ); Sat, 20 Mar 2010 16:06:22 -0400 Received: by gwaa18 with SMTP id a18so336305gwa.19 for ; Sat, 20 Mar 2010 13:06:21 -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=SnBS8ut69TTXqoeZQqIVWOAxoAVAaK9JN+f50/FltOk=; b=udkoSlH5Ch146DyGrIioWDtT5kSY2I6m15u7g3PP2Nm91ZhbrdDca9pDPZ+IUvSeTK HvQ0rbdhjBrk5XkZeuEVfRlRXtinnkrV1jx9hs6Cx8eu09KwPV1NLHWnUjv88RVmSuA9 nMuFjd6k8KEithK4urO0NxPWne238DK3SjEBg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=d1DQRrVEsBXhzOpj/Wb8Zt6cqMIsLgCxvzlv7fj66VgV+YikoFzNgT3OR/8cgalw0g Bu5WDTQGzb1FTU+3lGYGRqV6THUqERM+a3/uhWI0CeBLqUTsQ1HGyLzMuopLDQMeC1hL drjQhjFy7bfwsPqnxIE8C2/U5UwhL2Qx7MDjs= Received: by 10.101.186.30 with SMTP id n30mr2498692anp.180.1269115581810; Sat, 20 Mar 2010 13:06:21 -0700 (PDT) Received: from localhost.localdomain ([187.15.88.250]) by mx.google.com with ESMTPS id 34sm1017005yxf.0.2010.03.20.13.06.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 20 Mar 2010 13:06:21 -0700 (PDT) X-Mailer: git-send-email 1.7.0.2.280.g069ed 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 --- Rearragements and minor changes. Documentation/git-checkout.txt | 21 ++++++++++++++++- builtin/checkout.c | 13 ++++++++- t/t2017-checkout-orphan.sh | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 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..5a50997 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=