From patchwork Mon Sep 7 00:02:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11759789 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 CED6D112E for ; Mon, 7 Sep 2020 00:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B41852078E for ; Mon, 7 Sep 2020 00:03:44 +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="oHh57vAo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbgIGADf (ORCPT ); Sun, 6 Sep 2020 20:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbgIGADb (ORCPT ); Sun, 6 Sep 2020 20:03:31 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66297C061755 for ; Sun, 6 Sep 2020 17:03:30 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id b17so11063140ilh.4 for ; Sun, 06 Sep 2020 17:03:30 -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=xAZAVCNQGcdMhBwcRAu/Qilofw+kziw4Fw6pySYYf28=; b=oHh57vAocR9ig4AQ2oQtql8XpLEYgymQlemQ/CxBIv/y9BJCEJbyAMb3hlJHUwCd/c SGESsW3i9vAVcH8vnppyEvAqriw9k9xPQvEakDFQ3rVuzOofsqUwPwrLXJn4xRdwQtNd b29cVx+re7tqjNIXm+ta8zOq8DdXkK6IfMak38HNTD1NZBf60cJUMgTXxlz6Vgnwf2Iz biQ8YGWJ++lBWDLBfP7lBM2A3pu5IqsZr78CRr0cAp2Ijr6x6+V7VxZ96kBjmInUP3mm +fARhEqBeO573GBzk4iFnoXkDdxiBr2dxbxcEAMb3e+onLOHorpU/MKHmq8uhXkLrMmQ KszA== 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=xAZAVCNQGcdMhBwcRAu/Qilofw+kziw4Fw6pySYYf28=; b=ejQosw68vv1bHor1z1vfdpwy454n+5wd8xbLzWaLAKYLEnb3seqHRzKIP7q35OZj2s Wke+i4Zo/gFSamREGxcjEQYPkP/vWa/Tt2uwtHb30Sd2CLLarVI6nItS8RI4r+Vjy0YX X4g5tKtXtgpbYKWNmIygsfRvLcVJ7ePWQz9XtF1Dt2sI1bMHyzeRlj61uYWp4kW7qD4r Msd6Nt0d+43OjVJ2wwB/fuOryr6JcssukdHCsJ8gOpzTigpWYJQTX4DHd/QAMtJEkdac KXuJF9BSzDiKQ9L0ho+SBzuqnXoDRUwJI61RcD6Rz30pkL9wJLai+MxS3Ff8I2vAoy6y 3WVA== X-Gm-Message-State: AOAM532mxGJ7BnkdrnueLs6VysWx15UZEpuvJWuIFEupeUWq3oLAC7tQ N/227tDHEYkGO6AuNIwgdoUA8j6E9zU= X-Google-Smtp-Source: ABdhPJxiuw671BPj38oAb4WabnmPy4dQ76wAH2SHyz8XmXzWH0uf2K/YWqKCk4WAqeLck6Ji4iIlQg== X-Received: by 2002:a92:3007:: with SMTP id x7mr17149364ile.48.1599437003630; Sun, 06 Sep 2020 17:03:23 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id e22sm6381664ioc.43.2020.09.06.17.03.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2020 17:03:23 -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 v2 1/3] git-checkout.txt: document -d short option for --detach Date: Sun, 6 Sep 2020 20:02:20 -0400 Message-Id: <20200907000222.4717-2-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200907000222.4717-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> <20200907000222.4717-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 Mon Sep 7 00:02:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11759787 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 85E9F138E for ; Mon, 7 Sep 2020 00:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 652DC2078E for ; Mon, 7 Sep 2020 00:03:44 +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="KjhAdoaY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbgIGADe (ORCPT ); Sun, 6 Sep 2020 20:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726577AbgIGADb (ORCPT ); Sun, 6 Sep 2020 20:03:31 -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 5E4D9C061575 for ; Sun, 6 Sep 2020 17:03:30 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id y2so11055558ilp.7 for ; Sun, 06 Sep 2020 17:03:29 -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=KeaCPUTKce5yLNUpciFJF4pXv6s+59WsUq6KBmoFHVw=; b=KjhAdoaYz56lLAWv3ASopWRXu6vqZTQ2QJy/HtxQ0qXooAvXD5ZEwhowZb5MjvyOfL w3ohOJikw6WZK35YxjuCVP7LasJbf8/3WaviXlmJWU6qF8TV0757EHIrbRwoOTqnTab6 ryLJ0aYUSEiTS9mk0sdc13x4DwIOGu52zIw1yivFJ/D4ihmU5iKv0Op0a5sYIZ6vj9XJ DaOaNhKO9Ns4YtsZ6lEyjodfAaZ3hbxdbFM7zbv5QYmLB5T0zV08hIdE27IRe058W9WD TE9YmbV7cHI91nfPBbuhosO+MgkKHRNbBn75blWoN9y50Wgz+XvNg9q9jfkWg9RHn7F1 iH/w== 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=KeaCPUTKce5yLNUpciFJF4pXv6s+59WsUq6KBmoFHVw=; b=BSl7YEszuM3cDJ13+ivCZaMn+TfSBf5sbYh6YBfCQNHLiL8czopYv5Wp5FcQRG8MuF 3fUN1eHJjEC1GxgkQqGrOa5KbOhoCh/x8KcnyMl9M1zxUXdxzfjewhDCz+D6CMicVkcM 0hPh4bSXZRdqoqv8N8CY4SZBR085yOSaPFXIK8R9V6OXU91CzoPVF8M9/FFW0vTI7Iy4 Y1AWkIOOcgt2vUPgmFndWRYorfoQ8dLUZboi1lrnuQemPuLpRkDMoYCPnwXKhpIfgcwI hSI/jzWd5YlgUdxJ1WIvFiilmCdK6u9G1hmtk/IhU3JbLT9cuUM5xXHc2NjA1p0SWfGo 9C4g== X-Gm-Message-State: AOAM5311ogZZb6qHdcQoRZ35rt5SaWMvt+rZzrZEevHwyFXYdLZsr9lB BvHA4LmuW3LLZt5ql2nZhP/8BncWCRs= X-Google-Smtp-Source: ABdhPJz00mG94mX9hjZ03vLlYQk41N2nAXM41MDz1vabp6fl6PbwdAfeYYYl1oWDIAW9g8eqjiFhpw== X-Received: by 2002:a05:6e02:cd4:: with SMTP id c20mr17810082ilj.0.1599437004603; Sun, 06 Sep 2020 17:03:24 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id e22sm6381664ioc.43.2020.09.06.17.03.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2020 17:03:24 -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 v2 2/3] worktree: teach `add` to recognize -d as shorthand for --detach Date: Sun, 6 Sep 2020 20:02:21 -0400 Message-Id: <20200907000222.4717-3-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200907000222.4717-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> <20200907000222.4717-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 add` can check out a branch or set up a detached HEAD. However, unlike those other commands, `git worktree add` does not understand -d as shorthand for --detach, which may confound users accustomed to using -d for this purpose. Address this shortcoming by teaching `add` to recognize -d for --detach, thus bringing it 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 Mon Sep 7 00:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 11759791 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 000F717D4 for ; Mon, 7 Sep 2020 00:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D91092078E for ; Mon, 7 Sep 2020 00:03:44 +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="J8e7kdhF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbgIGADi (ORCPT ); Sun, 6 Sep 2020 20:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbgIGADc (ORCPT ); Sun, 6 Sep 2020 20:03:32 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E01C061573 for ; Sun, 6 Sep 2020 17:03:30 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id r25so1394200ioj.0 for ; Sun, 06 Sep 2020 17:03:30 -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=xeWVOiJ87uCRO69f4bfaQjLBAfla01P00ABjwpPLld0=; b=J8e7kdhFRZ41ajbdUmb8WckV+BfawQbf4Db5gl3bqeUFgFRXhplWVfojUz1CAdDDWi 7G14nrLpbo8vIwhOak6ZPftXlVvSvB1X0C7pwIDmnKv8e7KlytF5EVqjslmRtd8B+36H L5p5RpRGbuKj80Y26aonOdK1KedQ4+8/kHsO2F8QyH6arErOdnzYdoUIQPj2KCxQkz+R XDtBRRuQm57CWTcBn35F+80JFoVoZ0HRyzqx0Zzy8clA2eH3Osaozb1NbKOZXrk4uDIt n3veJg/CKUppVTfU8S2C1o7atm9bz+kThKmG+R2Atr7YA2jPYnVIX70EfKkjAldMDh6v CoLA== 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=xeWVOiJ87uCRO69f4bfaQjLBAfla01P00ABjwpPLld0=; b=OUhpvQdQ/kQRlXFCYnJ7CAIuF19eb+Kwc5Sl0h8ZlHFP66dwx/IIL0ZAyNDrGDqk2q nT+s9jBCJsKMjMD9O4vb1LL+cfJNwhklLgIyFS4U83BfYQWcywGfYZTFHbgqhq0b+3b3 0hwoHPQSj/RVHu4aPXopdsWyzHCEjnbKzfwj2/0sQd1Kn5JpFlTkT+NJeV6HXs4xSbQk yfemSTi5nuvrvMzfk6h6wNROAhyOsY65qCiv0QhiJDgc98t6O5BwFydgVlFLCqfZmoSi /8EPrNogbb9Meau50XsAE4NAUsB97jsEl0QXnEmeRWNsulnXzWdTrvUKZadJw6w9cejb qYgg== X-Gm-Message-State: AOAM532F/jW66aqoS/+BnOQX+BMWbnb/z6qG9afZL8WN5S1xoW/jLUYk fN7xB+jdvYCtzggKLaEcMezBjzlhiQQ= X-Google-Smtp-Source: ABdhPJzUm0Ykl4wkBYqLFFnzYpChW6uVkvg3Yd2xdGVL19ySjklmNTi+qKapJyTPG6VkjoYN/BMAgw== X-Received: by 2002:a05:6638:144f:: with SMTP id l15mr14906220jad.5.1599437005529; Sun, 06 Sep 2020 17:03:25 -0700 (PDT) Received: from localhost.localdomain (user-12l2dpj.cable.mindspring.com. [69.81.55.51]) by smtp.gmail.com with ESMTPSA id e22sm6381664ioc.43.2020.09.06.17.03.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2020 17:03:25 -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 v2 3/3] git-worktree.txt: discuss branch-based vs. throwaway worktrees Date: Sun, 6 Sep 2020 20:02:22 -0400 Message-Id: <20200907000222.4717-4-sunshine@sunshineco.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7 In-Reply-To: <20200907000222.4717-1-sunshine@sunshineco.com> References: <20200904070703.47898-1-sunshine@sunshineco.com> <20200907000222.4717-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 branches without realizing 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