From: Junio C Hamano <gitster@pobox.com>
To: Chris Torek <chris.torek@gmail.com>
Cc: Larry Martell <larry.martell@gmail.com>, Git List <git@vger.kernel.org>
Subject: Re: Can't checkout branch
Date: Tue, 14 Jul 2020 12:04:42 -0700 [thread overview]
Message-ID: <xmqqmu41lxyt.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <CAPx1GvcOpmpuPseAQDYk9pg+hfdF9KJSSSiB0fEHQrnUuPS4CA@mail.gmail.com> (Chris Torek's message of "Tue, 14 Jul 2020 11:17:56 -0700")
Chris Torek <chris.torek@gmail.com> writes:
> 2. Treat this as `git checkout -b deploy origin/deploy`
> or `git checkout -t origin/deploy`, i.e., create the
> branch `deploy` from `origin/deploy`.
>
> If *both* of these alternatives work, pre-2.23 Git *assumes* you
> meant alternative number 1. In 2.23 or later, `git checkout`
> tells you that this is ambiguous and makes you pick which one you
> want.
>
> To work around this in all versions of Git, you can just be
> more explicit. For instance:
>
> git checkout deploy --
>
> forces Git to treat it as a branch name.
I actually think "git checkout -t -b deploy origin/deploy" is a
better way to be explicit to avoid confusion. You do not create a
branch every few seconds anyway---it is more important to instill in
user's head what really does go on by encouraging them to give these
command line arguments explicitly, instead of teaching new people to
rely on "git guesses most of the time in your favor so here is the
lazy command line"---that will prevent true understanding and if it
left unremedied long enough, will result in a confused user who is
no longer a newbie.
Having said that, yes "git checkout deploy --" is a way to still
rely on git guessing most of the time in your favor to stay lazy,
and it should work, but there may be unseen other factors to break
the DWIM, just like Larry didn't think of an existing file deploy
in the working tree to be interfering.
Thanks.
next prev parent reply other threads:[~2020-07-14 19:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CACwCsY7YSn_mbtFv3QjL5dY80G6e_r-gGC3SGo5rO5b8LGXxVA@mail.gmail.com>
2020-07-14 16:59 ` Can't checkout branch Larry Martell
2020-07-14 18:17 ` Chris Torek
2020-07-14 19:04 ` Junio C Hamano [this message]
2020-07-14 20:29 ` Larry Martell
2020-07-15 7:00 ` Andreas Schwab
2020-07-15 14:50 ` Junio C Hamano
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=xmqqmu41lxyt.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=larry.martell@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).