From: Larry Martell <larry.martell@gmail.com>
To: Chris Torek <chris.torek@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: Can't checkout branch
Date: Tue, 14 Jul 2020 16:29:46 -0400 [thread overview]
Message-ID: <CACwCsY4p2LSVYK3iWKes2uA0oHj-HPdo4WS0OPzuxQuG7fDbOw@mail.gmail.com> (raw)
In-Reply-To: <CAPx1GvcOpmpuPseAQDYk9pg+hfdF9KJSSSiB0fEHQrnUuPS4CA@mail.gmail.com>
On Tue, Jul 14, 2020 at 2:18 PM Chris Torek <chris.torek@gmail.com> wrote:
>
> On Tue, Jul 14, 2020 at 10:04 AM Larry Martell <larry.martell@gmail.com> wrote:
> [snippage]
> > $ git fetch --all
> > Fetching origin
> > * [new branch] deploy -> origin/deploy
> >
> > $ git checkout deploy
> > $ git branch
> > * master
> >
> > $ git checkout origin/deploy
> > Note: checking out 'origin/deploy'.
> >
> > You are in 'detached HEAD' state.
> >
> > I tried deleting the local repo and recloning, but I got the same
> > results. I see the branch on github. I can checkout other branches,
> > just not this one.
> >
> > What could be going on?
>
> This happens in Git versions prior to 2.23 (what Git version are
> you using?) when there is a *file or directory* named `deploy`.
>
> What is happening is that since there is no *branch* named
> deploy (yet), you can't check it out (yet). So `git checkout
> deploy` initially fails. The checkout command then goes on
> to try two alternatives:
>
> 1. Treat this as `git checkout -- deploy`, i.e.,
> extract the file or subtree named `deploy` from
> the index (discarding changes to that file or
> subtree).
>
> 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.
Thanks for the reply - that was indeed the issue - I had a dir named deploy.
next prev parent reply other threads:[~2020-07-14 20:30 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
2020-07-14 20:29 ` Larry Martell [this message]
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=CACwCsY4p2LSVYK3iWKes2uA0oHj-HPdo4WS0OPzuxQuG7fDbOw@mail.gmail.com \
--to=larry.martell@gmail.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
/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).