From patchwork Fri Sep 4 07:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11755935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE2CE15AB for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97104206D4 for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c7QBS38w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbgIDHIr (ORCPT ); Fri, 4 Sep 2020 03:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726597AbgIDHIo (ORCPT ); Fri, 4 Sep 2020 03:08:44 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ABBDC061245 for ; Fri, 4 Sep 2020 00:08:42 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id t13so5464792ile.9 for ; Fri, 04 Sep 2020 00:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=udNH8yeHpFWVdd6YQu9UgrG4522T0NXseoi3Jzs2Z0A=; b=c7QBS38wNxpR9RFK+PyhnCBJJgMwvOKa5s1Y0tin9lutXzASV2txj3BEWPhanT8O+E MBO6yw39tiU33Z3Jq73TEMClBjz4kfawdRg9ImQzdAb3+n9tfE+i1rlvhdsUarqEghEe rXYntbKNyRlBjbyljFcdimB+0w28PRjaskBAx/veQAIn/MZtt4aZpuGjrvesOGP9Kdlm cgIlerk1A9aygxE7MUa5cB/F2jcDO+fsacxeLbw3WRvVtdwe7doi7U5zVkDUm1oIlzTi 67ICBZzTKntCQb9naYSjcrB7vys94b8ZZ54RgxwF7L6SbsqAcrBNRHOSsQJ93mZlrvMA IcMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=udNH8yeHpFWVdd6YQu9UgrG4522T0NXseoi3Jzs2Z0A=; b=YZ3u1f/FhG43WuSRbmmc4KDwwCBQ5hOaptZ3wOAJMbcUotlJ51eDZYQutHShiRlfHt HhCuxrxPZnTUbFSgYhKgvwk4HTKr104F7oBp+W7A2C7begOXziI6eXlofKOdq6/198FP getsIGsuBbDZqhhAUjKDRVZ/XPsPpkLCnEQ67q8/zzPzfrYgKhmXdFubvthM9SewT5Qq x2/z1AEx24xQeI3nuYjSO0K/Njt2VQuMe1PoLOf28f3w+hZSBqxjpAKsntVcrP+stt0A 0AKj1bTe+6c8C669jzKkcJ1cAZlCup9V1GJvXQfnMEQAt7TxCideywqgw6cL5q1/6jNJ YDTg== X-Gm-Message-State: AOAM530TqmwlkwKbMNBWwNNPWjfGJAkOGDBxuk8dsR40+nTvWtsj8pLK g0A4Xn0HQrjbvD3TWpa5uuL66RBgPLA= X-Google-Smtp-Source: ABdhPJxNmiCTxUI4dedIh6IbchRGiiZY84eXAWZ5o3H9Md2t0E8ocUycONrTEsoPvEfu7UKvZaxT6A== X-Received: by 2002:a05:6e02:ee9:: with SMTP id j9mr4509233ilk.18.1599203321489; Fri, 04 Sep 2020 00:08:41 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id n62sm2881950ild.36.2020.09.04.00.08.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2020 00:08:41 -0700 (PDT) From: Eric Sunshine To: git@vger.kernel.org Cc: Pratyush Yadav , =?utf-8?q?SZEDER_G=C3=A1bor?= , Junio C Hamano , Eric Sunshine Subject: [PATCH 1/3] git-checkout.txt: document -d short option for --detach Date: Fri, 4 Sep 2020 03:07:01 -0400 Message-Id: <20200904070703.47898-2-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200904070703.47898-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org git-checkout learned -d as short option for --detach in 163e3b2975 (switch: add short option for --detach, 2019-03-29) but the documentation was never updated to reflect the change. Signed-off-by: Eric Sunshine --- Documentation/git-checkout.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 5b697eee1b..afa5c11fd3 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -198,6 +198,7 @@ Use `--no-guess` to disable this. Create the new branch's reflog; see linkgit:git-branch[1] for details. +-d:: --detach:: Rather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. From patchwork Fri Sep 4 07:07:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11755933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91B3B1599 for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AB52206D4 for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HODFVf4c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbgIDHIp (ORCPT ); Fri, 4 Sep 2020 03:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgIDHIo (ORCPT ); Fri, 4 Sep 2020 03:08:44 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A615DC061244 for ; Fri, 4 Sep 2020 00:08:43 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id x2so5519339ilm.0 for ; Fri, 04 Sep 2020 00:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y7edZzxRMYWOYMK4RX7tgA1J0yGQOgeOuW3LE5RNHKM=; b=HODFVf4cudO70vuc1p8ljOLI0TZgai1mQj4XITS83DpcrHcw/GnjMWdSPJclqoBgee S5X6JenIh3X9esQX8WfWOeGY40rRuhQNIrbdao90zu8B4020SJjoyFPcasXoluHhHqh8 YKn0VOlCZczPjmFu2ZwBh6on2+J92hsapHCdjYj6n7V8Xr06N0pICMYjGddNx67OckbO ZlPP+66BHnhgIwgTqehPFIaU9uMHDzppS1foUgDzlKULWQABDnvD+SqZ5KGDvZJrXXE2 /BsOGM1I8zEbNvIRXn/lipvdJYUDeouiWPnJSNxg52bUakUXqBqkC7PuPEZOfLUO7dNC wfog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=y7edZzxRMYWOYMK4RX7tgA1J0yGQOgeOuW3LE5RNHKM=; b=YmTbFzfoZy8iyHsJvR26ox/cRC3fEZi3vIdEh+PEH9o+UmzSc+GwI41/cBJcLT45gP PndmE+WooD94wayUJXtg98Uu7TFE4Ew4V+D57qNtjzbBvm4FaKE6e1nN7HnO4N1+VKNt DydIVTTFn2SEB5gIWDnVz2Hs35pcvgdiPKGSFDMlS9o7+7HFhzHVqppvMFJURQOO7Ima 8kF0O7xrm7W5Z/DgT7/OFLkcDSqe5bhSNY9KbfEJh65Nz7AaNViZ4LNnBRFzarEA5nxT fBVcqCuMUrrybqPhhQURJNwaf+/JLumdH+Kd/YvgOumdEO3ixiuKrOZsCXuicWkRTGHg LYMA== X-Gm-Message-State: AOAM5301AQS9PEZ9ahSmIqxsbVCek5hOJfgPM7B+K9Wge5v6f5nSaNch tD7EmuzsgnMifjcQjv/sajdqSjkwt+s= X-Google-Smtp-Source: ABdhPJwSqSMi/JWGBcMShJLBEVjA6zxUrLf2vwIaU3GCM/ZEKm4WMUKzoYNOFm18c8AZqfhKtxYeBQ== X-Received: by 2002:a05:6e02:1303:: with SMTP id g3mr3541333ilr.218.1599203322685; Fri, 04 Sep 2020 00:08:42 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id n62sm2881950ild.36.2020.09.04.00.08.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2020 00:08:42 -0700 (PDT) From: Eric Sunshine To: git@vger.kernel.org Cc: Pratyush Yadav , =?utf-8?q?SZEDER_G=C3=A1bor?= , Junio C Hamano , Eric Sunshine Subject: [PATCH 2/3] worktree: add -d short option for --detach Date: Fri, 4 Sep 2020 03:07:02 -0400 Message-Id: <20200904070703.47898-3-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200904070703.47898-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Like git-switch and git-checkout, git-worktree can check out a branch or set up a detached HEAD. However, unlike git-switch and git-checkout, git-worktree does not understand -d as shorthand for --detach, which may confound users accustomed to using -d for this purpose. Address this shortcoming by adding -d as shorthand for --detach in order to bring git-worktree in line with the other commands. Signed-off-by: Eric Sunshine --- Documentation/git-worktree.txt | 1 + builtin/worktree.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 6ee6ec7982..d252b6873b 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -143,6 +143,7 @@ To remove a locked working tree, specify `--force` twice. exists. `-B` overrides this safeguard, resetting `` to ``. +-d:: --detach:: With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD" in linkgit:git-checkout[1]. diff --git a/builtin/worktree.c b/builtin/worktree.c index 378f332b5d..1737165d2d 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -555,7 +555,7 @@ static int add(int ac, const char **av, const char *prefix) N_("create a new branch")), OPT_STRING('B', NULL, &new_branch_force, N_("branch"), N_("create or reset a branch")), - OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")), + OPT_BOOL('d', "detach", &opts.detach, N_("detach HEAD at named commit")), OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")), OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")), OPT__QUIET(&opts.quiet, N_("suppress progress reporting")), From patchwork Fri Sep 4 07:07:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11755937 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D368691F for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2FE3206D4 for ; Fri, 4 Sep 2020 07:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IveFyqDP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbgIDHIt (ORCPT ); Fri, 4 Sep 2020 03:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbgIDHIq (ORCPT ); Fri, 4 Sep 2020 03:08:46 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CCC2C061244 for ; Fri, 4 Sep 2020 00:08:45 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id h4so6138143ioe.5 for ; Fri, 04 Sep 2020 00:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9i3kuZlAqjrdQo1iLQhsd8GMLeoUz/SnVkf+bbekH9M=; b=IveFyqDP8fi9MUyOB9keKYGRohF8c0sLf2JACQtLGe89PAExPhNqWKJ5u907OGjKhv NuSEZx6zUl4p7bjGziIStiAl8fbMKR7kUyHjOrf2A6gEsIfa3JUzng4X6MNKizMNlcMs lM/Nl0bcyC5fvVfPO6in0nbEbdqqB2V8laC3UBw29qH+m7iKHPA9s+S0Oz+DhAJgVar2 uHDwMFNvCOLbJ2vmeqdosYf285vnmgHycEH7cfkia9gM/E1dlP/a7zsAP0AUO1L+R22L EjlQ20mTbmr6EnjuVLyQxQ1MR7cwYmXWO4HrQYLAaK0pWC88+qab7LMPb1tnFlJeEOfc sr+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9i3kuZlAqjrdQo1iLQhsd8GMLeoUz/SnVkf+bbekH9M=; b=ZiQlXTXk2z+EBaTGG3AyUUgYMAKn9km/Fl7nLMw23Yu0GmBL7/eQQi2ehZ+BVIwvx/ zCPDLd9oo3FDnr0B5H/cr76ciC/ogywM+vWcTQyagmOyzqzMKSyel8UQglhs+UEUNt2R MlcR9GyzuHm/eb7Zk7u/jJsZneAzlPxvstqj2bWYenA5XMuhsScQYkkHaBgjt2Bit1xt roBHSp1CmJ+yz5hamHmJSX+Q2SVsy1e+smWU/XGOyX0N/xwsVMGDkujyGgCb2cPd/Tz/ PiK97jwr+ch/BmRAeiTLtNUbwJnw54oJTpN9f3qQVIBRVf9bAdCLsDoPzNFDLSIsChxW 5JmQ== X-Gm-Message-State: AOAM530O8M7bz33Se7CgTBAJn0o8RxOLvko8XCOrwgj1wQQoJAPWISTD 2QGOvUuxC/WpkuzEMbRWFmuscRqH+X0= X-Google-Smtp-Source: ABdhPJya1F7gn3RW5VerrdTmfFOoRBPUgshRnpzC5PG4KDIQ5m+4geK116UKXihIGWR9uT1BV76bEw== X-Received: by 2002:a02:3502:: with SMTP id k2mr6924634jaa.129.1599203323651; Fri, 04 Sep 2020 00:08:43 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id n62sm2881950ild.36.2020.09.04.00.08.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2020 00:08:43 -0700 (PDT) From: Eric Sunshine To: git@vger.kernel.org Cc: Pratyush Yadav , =?utf-8?q?SZEDER_G=C3=A1bor?= , Junio C Hamano , Eric Sunshine Subject: [PATCH 3/3] git-worktree.txt: discuss branch-based vs. throwaway worktrees Date: Fri, 4 Sep 2020 03:07:03 -0400 Message-Id: <20200904070703.47898-4-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200904070703.47898-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org By default, "git worktree add" creates a new worktree associated with a particular branch (which may have been created automatically if not specified explicitly on the command-line). It is also convenient to create throwaway worktrees not associated with any branch, which can be handy when making experimental changes or doing testing. However, the latter use-case may not be obvious to newcomers since the high-level description of worktrees talks only about checking out "more than one branch at a time". Therefore, enhance the description to to discuss both use-cases. A secondary goal of highlighting the distinction between branch-based and throwaway worktrees is to help newcomers understand that the simplest form `git worktree add ` automatically creates a new branch. Stating this early in the description, may help newcomers avoid creating unwanted new branches without being aware that they are doing so, and later wondering why `git branch --list` shows branches the user did not intentionally create. Signed-off-by: Eric Sunshine --- Documentation/git-worktree.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index d252b6873b..1449491c1b 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -31,6 +31,18 @@ A repository has one main working tree (if it's not a bare repository) and zero or more linked working trees. When you are done with a linked working tree, remove it with `git worktree remove`. +In its simplest form, `git worktree add ` automatically creates a +new branch whose name is the final component of ``, which is +convenient if you plan to work on a new topic. For instance, `git +worktree add ../hotfix` creates new branch `hotfix` and checks it out at +path `../hotfix`. To instead work on an existing branch in a new working +tree, use `git worktree add `. On the other hand, if you +just plan to make some experimental changes or do testing without +disturbing existing development, it is often convenient to create a +'throwaway' working tree not associated with any branch. For instance, +`git worktree add -d ` creates a new working tree with a detached +`HEAD` at the same commit as the current branch. + If a working tree is deleted without using `git worktree remove`, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (see