From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 025512D640D for ; Fri, 29 Aug 2025 11:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756467939; cv=none; b=lVySwtAQhMXDQRVFh9V1mx+Az0qGhHSt4OUAqnwofrTmPd4X8YTVLNHceu6dDOhwAHQatKxa5CTMyXjq5WY46QYKWyu92iGZzm2NKumxVx5wUSKVB+YE2KlPTeY+PTt1GXk0t9Wl8CCYS0rccMrcDtPAvITXePWN4/r76WhRagE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756467939; c=relaxed/simple; bh=+tcP8D7Bo0N+b6/Vp8y+vT4XotetKcL3pUmBOtk4qUw=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=tVRntC60Nn8Noq5WGuO5Ue/zvquU69OD1ug/9E667QhaS/x4E8Zms1AaJpNpDiXJO1h+ZnMtHXTQrXGnL5KzebHr0I1PkaTsdbymEgVbP63Epprh0hRfal2nWHhwtaef6AdQ7j++Tz+8xw6EKuffl8hsa6vqpnAkdGgYBgJ9WCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FrjojUuY; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FrjojUuY" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7f861f89313so189516785a.1 for ; Fri, 29 Aug 2025 04:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756467936; x=1757072736; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=HJ8SyCHLF4l7hocUmAybAjP72a1XW25REFbV6sTq/9U=; b=FrjojUuY311XLBpnXFPkFF9e1YOnfqaiWDqlXLOOqEpTcgZwtvns7r7mLvfIG23a9A TM4f4bxtUFTr1iLYVQOBtN15S4f4iHGnhVaRQYcghhK1V/pqfjnC8UTRsX9L52hyt2PG ok9Cf77MpkHf9NOiT++K9sJbQ8oE4TX4lAkTWww6x9APZBq7iPYGkeZeAgKc/Pyb369Y Gi72uznx/3EzG8FBOiSju5U3uzWv7U9Pe/CcGescIL2LF9bEbzjC1Q4F3jXy5JP1M+pX CGC8AWFuQiW0mdqPjxBvjhsK2rplo+ecV08GKCfaN/YXKbtaerIeIS5JgNo8ULmN5jMY nutw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756467936; x=1757072736; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HJ8SyCHLF4l7hocUmAybAjP72a1XW25REFbV6sTq/9U=; b=I+tAFPODdIXNV6qgfu3uAGUKfGOrhXvh7WxagOkT3rOpTizUYuiYv01c+JpJcHT4X3 0dRgcGzEuK7IFi+hTJjIwqMbwFGIq571IgXCxAVUld9YRY2tqeE+1CEa+rLKCcs8Y32A yN0cHfVDg21XwDGaJh+iOj1FYUKm5ywk6VbJ/RtZ39/wQfiJg+1qoOvylZ7hIKieNEN9 PQVb9iRENALnkDqk/YKjvbdWaXdwvA8Ozha6AjZx735ZWmQKK+YPE+N173WGWgIuHoN7 zEBd9uD5+SboR4QfNLGSZzA3UMILeRtzhksU8/6yJMIbNNSEGNeWRpmLb0k6XkbK/nOd o5UA== X-Gm-Message-State: AOJu0YxrG090N2dcY1Le4cZSOxcxYDmunkTNgoqVBV7Izu68Pf8fkjvf rjHG9H/8uwi8FWxjuBn1IzWtorRizxnaWum0sCFcIm8Z/kLZVTaLgBMzex/41XTu X-Gm-Gg: ASbGncsl+4Vawk2Fcw6/wSlEnsBlpiyMT6TX5Cmb0SjJXLRN4Tv95fs5W7QFWn/Inpp KQJpwD6Z93GKukI9OiMVwtQcyuAMsdBlpoD1VuBQpbOPLU0QFqvMzIJ38mihifjCVhUUZTpuEEF kAhnV/8kZjP2C2m03GxP0UxbCzUj/BR/N3jztaaaBw9OwRmDKrRr5cUVQ/hSo6Nm8+N/XUO1u8I m7EYqEcqp7tkAY4piEFMpySoW2GBLbpbAzDg38LrhiFlfCMBAzkP+5sZUukwOfkZ5l4FOGhLIad 25uOrzvhh24f+BezPQif0S4JbKgveVIO4fOBgqU2kdSj20MaCVigqRHLZIbBHWH7Wlsafvk2+zV KlJGnLMS0iGqek5JJYKKQoh6oXgfyNJwqrg== X-Google-Smtp-Source: AGHT+IG6Gys6+uWP7or2k6l5Fye8GT/i0yY7YtgNts6gTFzTZ52uIovWwrUZE3eSWibGJH+FLxNRCw== X-Received: by 2002:a05:620a:4593:b0:7f9:c004:42e with SMTP id af79cd13be357-7f9c0040489mr771156785a.0.1756467936303; Fri, 29 Aug 2025 04:45:36 -0700 (PDT) Received: from [127.0.0.1] ([20.57.47.232]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7fc151f17b8sm154713285a.50.2025.08.29.04.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 04:45:35 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Julia Evans via GitGitGadget" Date: Fri, 29 Aug 2025 11:45:29 +0000 Subject: [PATCH v2 0/5] doc: git-checkout: clarify DESCRIPTION section Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: "D. Ben Knoble" , Julia Evans * Remove the numbered list from the beginning * Split up the git checkout [] section into two sections, one for git checkout and one for git checkout , to match the SYNOPSIS and because it seems like a clearer approach. Also completely rewrite them to be more accurate and more clear. Use "Replace" instead of "Restore". * Describe what it means to "switch branches" in a way that's more accessible to newcomers, and make "If the local changes conflict with the changes on ..." more accurate * Improve the ARGUMENT DISAMBIGUATION section Julia Evans (5): doc: git-checkout: clarify intro doc: git-checkout: clarify `git checkout ` doc: git-checkout: don't use "reset" doc: git-checkout: deduplicate --detach explanation doc: git-checkout: clarify restoring files section Documentation/git-checkout.adoc | 114 +++++++++++++++++--------------- 1 file changed, 60 insertions(+), 54 deletions(-) base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1962%2Fjvns%2Fclarify-checkout-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1962/jvns/clarify-checkout-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/1962 Range-diff vs v1: 1: a6125a0128 ! 1: 48e7f23029 doc: git-checkout: clarify intro @@ Documentation/git-checkout.adoc: git checkout (-p|--patch) [] [--] [

` -+2. **Restore a different version of a file**, for example with `git -+ checkout ` or `git checkout ` ++`git checkout` has two main modes: it can ++**switch branches**, for example with `git checkout `, and ++**restore files from a different version**, for example with ++`git checkout ` or `git checkout ` + +See ARGUMENT DISAMBIGUATION below for how Git decides which one to do. -+Here's a description of all of the modes: `git checkout []`:: To prepare for working on __, switch to it by updating @@ Documentation/git-checkout.adoc: $ git log -g -2 HEAD +`` is intended to be a branch, a commit, or a set of file(s), +and then switches branches, switches commits, or restores the files. + -+If there's a conflict, you can use the double dash `--` to distinguish -+between branches and files: ++If there's any ambiguity, Git will treat `` as a branch or ++commit, but you can use the double dash `--` to force Git to treat the ++parameter as a list of files and/or directories, like this: + -+* `git checkout --` will force Git to treat the parameter as a -+ branch name or commit -+* `git checkout -- ` will force Git to treat the parameter as -+ a set of file(s) ++---------- ++git checkout -- file.txt ++---------- EXAMPLES -------- 2: b8873c4529 ! 2: 23a738981a doc: git-checkout: clarify `git checkout ` @@ Commit message Signed-off-by: Julia Evans ## Documentation/git-checkout.adoc ## -@@ Documentation/git-checkout.adoc: See ARGUMENT DISAMBIGUATION below for how Git decides which one to do. - Here's a description of all of the modes: +@@ Documentation/git-checkout.adoc: DESCRIPTION + See ARGUMENT DISAMBIGUATION below for how Git decides which one to do. `git checkout []`:: - To prepare for working on __, switch to it by updating @@ Documentation/git-checkout.adoc: See ARGUMENT DISAMBIGUATION below for how Git d - `HEAD` at the branch. Local modifications to the files in the - working tree are kept, so that they can be committed to the - __. -+ Switch to __. This will update the files in the working tree, -+ point `HEAD` at the branch, and update the index. Local changes to ++ Switch to __. This sets the current branch to and ++ updates the files in your working directory. Local changes to + the files in the working tree are kept, so that they can be committed -+ to the __. If the local changes conflict with the changes on -+ __, no changes will be made and the checkout operation will -+ fail. ++ to the __. If the local changes can't be cleanly merged into ++ the __, no changes will be made and the checkout operation will fail. + If __ is not found but there does exist a tracking branch in exactly one remote (call it __) with a matching name and @@ Documentation/git-checkout.adoc: exactly one remote (call it __) with a -"check out the current branch", which is a glorified no-op with -rather expensive side-effects to show only the tracking information, -if it exists, for the current branch. -+Running `git checkout` without specifying a branch will output the -+tracking information, if it exists, for the current branch, but it's -+slower than getting the same information from `git status`. ++Running `git checkout` without specifying a branch has no effect except ++to print out the tracking information for the current branch. `git checkout (-b|-B) []`:: 3: 0a3915264b ! 3: 360051d2a6 doc: git-checkout: don't use "reset" @@ Commit message Signed-off-by: Julia Evans ## Documentation/git-checkout.adoc ## -@@ Documentation/git-checkout.adoc: slower than getting the same information from `git status`. +@@ Documentation/git-checkout.adoc: to print out the tracking information for the current branch. `--track` without `-b` implies branch creation; see the description of `--track` below. + 4: 2221a6bfb5 = 4: 6f3e485c33 doc: git-checkout: deduplicate --detach explanation 5: b641874627 ! 5: 9c0119e70d doc: git-checkout: clarify restoring files section @@ Metadata ## Commit message ## doc: git-checkout: clarify restoring files section - - Use the term "Restore" to mirror `git restore` + - Split up the forms `git checkout file.txt` and + `git checkout main file.txt` to match what's given in the SYNOPSIS + - Remove `-f` from the SYNOPSIS for the second form, since according to + this man page it is not relevant in that context - Many Git users do not know what a "tree-ish" is. Clarify by using an example of each case, and by saying "commit or tree" in the text instead of "" @@ Commit message file's contents" where appropriate, since Git often uses "stage" as a verb to mean the same thing as "add to the index" and it's a more familiar term. + - Use "Discard unstaged changes" instead of "checking out paths from + the index" where relevant Signed-off-by: Julia Evans ## Documentation/git-checkout.adoc ## -@@ Documentation/git-checkout.adoc: Omitting __ detaches `HEAD` at the tip of the current branch. - `git checkout [-f|--ours|--theirs|-m|--conflict=