From: Junio C Hamano <gitster@pobox.com>
To: Steve Heyns <notzippy@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: "git checkout" resets modified files
Date: Sat, 29 Aug 2015 00:15:45 -0700 [thread overview]
Message-ID: <xmqqlhcuzhsu.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CANDob0LdQpoSfsedPK_yhNunXBvNTc9L1zKOM9h8dBUDePs0kg@mail.gmail.com> (Steve Heyns's message of "Fri, 28 Aug 2015 23:15:52 -0700")
Steve Heyns <notzippy@gmail.com> writes:
> "git checkout" resets modified files
>
> Version git 2.5.0,
>
> Description:
> I was automating a process that would pull and switch to another
> branch when I stumbled across this. I have not been able to emulate
> this from command line but using go (or I imagine other languages are
> similar) if you execute a command like
>
> exec.Command("git","checkout","")
>
> A checkout with the branch parameter but the branch parameter is empty.
It is not feeding an empty branch parameter [*1*]. It is asking Git
to check out all paths that match a pathspec "" out of the index.
Now, arguably, the user who would want to match everything may be
more likely to give "." as the pathspec (or if she is not at the
root of the working tree, ":/"), but "" means the same thing as ".",
and the requested behaviour "check out all that match this pathspec
from the index" would essentially mean "I want to get rid of all the
modification in my working tree relative to the index".
I do not think this behaviour depends on the vintage of Git. An
empty string as pathspec has always matched "everything in here"
AFAIR.
[Footnote]
*1* Checking out a branch whose name is an empty string can be asked
explicitly by disambiguating double-dash like this:
$ git checkout "" --
And it will be answered (correctly) with:
fatal: invalid reference
next prev parent reply other threads:[~2015-08-29 7:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-29 6:15 "git checkout" resets modified files Steve Heyns
2015-08-29 7:15 ` Junio C Hamano [this message]
2015-08-29 7:58 ` 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=xmqqlhcuzhsu.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=notzippy@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