All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Ramsay Jones <ramsay@ramsayjones.plus.com>,
	 "D. Ben Knoble" <ben.knoble@gmail.com>,
	 Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	 Marc Branchaud <marcnarc@gmail.com>,
	Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH v5] checkout: extend --track with a "fetch" mode to refresh start-point
Date: Mon, 04 May 2026 05:59:47 +0900	[thread overview]
Message-ID: <xmqqse88ryyk.fsf@gitster.g> (raw)
In-Reply-To: <pull.2281.v5.git.git.1777367012441.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Tue, 28 Apr 2026 09:03:32 +0000")

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A common workflow is:
>
>     git fetch origin
>     git checkout -b new_branch --track origin/some-branch
>
> The first command exists so the second sees an up-to-date view of the
> remote. If it is forgotten, origin/some-branch points at a stale
> commit and the new local branch is created from the wrong start
> point.

As I pointed out multiple times, I prefer not to see this called
"wrong".  Even if you did not "forget", somebody may be pushing
after you fetched and you may end up forking from a "stale" commit.
So not fetching is not inherently "wrong", simply because that is
how real world works.  Multiple people working in a distributed
environment does not give you absolute garantee that you will be "up
to date", ever, which makes it wrong to call anything that is not
"up to date" a "wrong starting point".

> This only matters when the user is setting up tracking and
> expects the new branch to start at the freshest tip; for a one-off
> checkout of an arbitrary commit there is no reason to "freshen" the
> start-point.

I do not think "arbitrary" fits in this workflow description.

If anything, "I'd take anything that the remote repository happens
to have at the tip, even without having a chance to sanity checke if
that is a good starting point" is more appropriate workflow to be
described with a word "arbitrary commit".

If you are checking out without forking from there, you'd more
likely be checking out the "latest" you have fetched from the other
side, often knowing exactly what it is after checking it with "git
show origin/$topic".

> Tie the new behavior to --track for that reason:

Notice that the reader hasn't heard what "the new behaviour" is up
to this point yet?

How about rewriting everything up to and including this "Tie the new
..." line perhaps like so:

    If you want to fork your topic branch from the very latest of
    the tip of a branch your remote has, you would do:

	git fetch origin some-branch
	git checkout -b new_branch --track origin/some-branch

    Extend the "--track" option of "git checkout" and allow users to
    write

	git checkout --track=fetch -b new_branch origin/some_branch

    to (1) fetch 'some-branch' from the remote 'origin', updating
    the remote-tracking branch 'origin/some-branch', (2) arrange
    subsequent 'git pull' on 'new_branch' to interact with
    'origin/some_branch' and (3) fork 'new_branch' from it.
   
    In the value of the '--track' option, 'fetch' can be combined
    with ...

  reply	other threads:[~2026-05-03 20:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 10:03 [PATCH] checkout: add --fetch to fetch remote before resolving start-point Harald Nordgren via GitGitGadget
2026-04-24 13:48 ` Ramsay Jones
2026-04-24 17:12 ` D. Ben Knoble
2026-04-25 17:24   ` Comments on Phillip's review Harald Nordgren
2026-04-25 17:44     ` Wrong subject line Harald Nordgren
2026-04-24 17:38 ` [PATCH] checkout: add --fetch to fetch remote before resolving start-point Kristoffer Haugsbakk
2026-04-25 17:41   ` Comments on Phillip's review Harald Nordgren
2026-04-25 17:44     ` Wrong subject line Harald Nordgren
2026-04-26  7:07       ` Kristoffer Haugsbakk
2026-04-26 15:15         ` [PATCH] remote: add --set-head option to 'git remote add' Harald Nordgren
2026-04-24 17:42 ` [PATCH] checkout: add --fetch to fetch remote before resolving start-point Marc Branchaud
2026-04-25 17:48   ` Wrong subject line Harald Nordgren
2026-04-24 22:21 ` [PATCH] checkout: add --fetch to fetch remote before resolving start-point Junio C Hamano
2026-04-25  2:54   ` Junio C Hamano
2026-04-25 17:58     ` Multiple remotes Harald Nordgren
2026-04-25 21:57       ` Ben Knoble
2026-04-25 22:54         ` gh Harald Nordgren
2026-04-25 18:12 ` [PATCH v2] checkout: add --fetch to fetch remote before resolving start-point Harald Nordgren via GitGitGadget
2026-04-26  7:24   ` [PATCH v3] " Harald Nordgren via GitGitGadget
2026-04-26 15:54     ` Ramsay Jones
2026-04-26 18:32     ` [PATCH v4] " Harald Nordgren via GitGitGadget
2026-04-28  1:47       ` Junio C Hamano
2026-04-28  8:44         ` [PATCH] " Harald Nordgren
2026-04-28  9:03       ` [PATCH v5] checkout: extend --track with a "fetch" mode to refresh start-point Harald Nordgren via GitGitGadget
2026-05-03 20:59         ` Junio C Hamano [this message]
2026-05-03 22:32           ` [PATCH] checkout: add --autostash option for branch switching Harald Nordgren
2026-05-03 22:31         ` [PATCH v6] checkout: extend --track with a "fetch" mode to refresh start-point Harald Nordgren via GitGitGadget
2026-05-07 20:12           ` Harald Nordgren
2026-05-08 13:15             ` Phillip Wood
2026-05-08 22:40               ` [PATCH] checkout: add --fetch to fetch remote before resolving start-point Harald Nordgren
2026-05-08 22:52           ` [PATCH v7] checkout: extend --track with a "fetch" mode to refresh start-point Harald Nordgren via GitGitGadget
2026-05-11 13:16             ` Phillip Wood
2026-05-11 13:47             ` [PATCH v8] " Harald Nordgren via GitGitGadget
2026-05-12  0:32               ` Junio C Hamano
2026-05-12 10:55               ` [PATCH v9] " Harald Nordgren via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqse88ryyk.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=haraldnordgren@gmail.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=marcnarc@gmail.com \
    --cc=ramsay@ramsayjones.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.