From mboxrd@z Thu Jan 1 00:00:00 1970 From: Erick Mattos Subject: [PATCH v3] git checkout: create unparented branch by --orphan Date: Sun, 21 Mar 2010 12:34:38 -0300 Message-ID: <1269185678-3039-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 Sun Mar 21 16:34:57 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 1NtNB0-00028k-5F for gcvg-git-2@lo.gmane.org; Sun, 21 Mar 2010 16:34:54 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386Ab0CUPet (ORCPT ); Sun, 21 Mar 2010 11:34:49 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:61686 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751299Ab0CUPes (ORCPT ); Sun, 21 Mar 2010 11:34:48 -0400 Received: by gwaa18 with SMTP id a18so580671gwa.19 for ; Sun, 21 Mar 2010 08:34:47 -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=Sy2X57vZbOlWaM/xwA6P6ynRWL2k4cXPRnmY/uNX2x4=; b=uoqu5V7CvdAiwLI6AB2qGN35E6CZdsb+oczvfVVpiLzRXPJ2jsyepr48F8BaLtsnf0 1+TVDMxYBRMH/OWoQ+2JEX09XqLsMGe5ox+WmCdxeQa4GBH/7nIRfDQkybO+Cqjrq6E9 7oB9igozu9ni0R2z6399BR2fBtx4E4987buKI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=r3fbfAbBb3Y0Tvcsll8l3+gPNpR9H7OBn6bU4oyF2S3ZjpL9ci0H37LiytDyKFF7dc q/zyjMRo2m/lRsNnnGHXr6GRdYl1lNWYxoSfZpU/yudH83et6DDnUZJTBNaFHofXoBOr TyUF/UqpVvJ+lOtN8dyf1TPRqGnnfFVn7HuoI= Received: by 10.90.24.13 with SMTP id 13mr678794agx.84.1269185687058; Sun, 21 Mar 2010 08:34:47 -0700 (PDT) Received: from localhost.localdomain ([187.15.37.88]) by mx.google.com with ESMTPS id 7sm181080yxd.44.2010.03.21.08.34.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Mar 2010 08:34:46 -0700 (PDT) X-Mailer: git-send-email 1.7.0.2.324.g7eb48.dirty 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 --- Final patch version (I think so... :-) ). Added some further script tests by Junio. Documentation/git-checkout.txt | 21 +++++++++- builtin/checkout.c | 15 ++++++- t/t2017-checkout-orphan.sh | 90 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 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=