git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Checkout file without changing index?

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Apr 24, 2019, 18:15 UTC
Message-ID
<CAA01CsrsSQ-_bhS_T5gxDqtPa0XKbHp1c7WCgdxLVvEA3fBSGA@mail.gmail.com>
In-Reply-To
<xmqq5zr31poo.fsf@gitster-ct.c.googlers.com>
On Wed, Apr 24, 2019 at 3:46 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
>
> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:
>
> > I was familiar with "git checkout revision -- file".
> >
> > But it updates both working tree and index. I had some changes in
> > index (staged) and "git checkout HEAD -- file" silently overwritten
> > it. Well, probably my mistake, it's documented.
>
> We'd invite you to live on the leading edge and try
>
>     $ git restore --source=<revision> <pathspec>
>
> which by default checks things out only to the working tree, but not
> to the index (you say --staged if you want to restore to the index,
> and you say --worktree if you want to restore to the working tree,
> or you can say both, which would be the same as "git checkout").

Thanks, looks nice. git-checkout is a bit inconsistent at what it does, and I understand the git-restore and git-switch are a better replacement for it.

> I think the new command is now on the 'pu' branch, but in a few
> weeks hopefully it will appear on the 'next' branch.
Is it possible to get a Windows build?
-- 
Piotr Krukowiecki
Previous: Junio C HamanoNext: Philip Oakley
Message 3 of 6 in “Checkout file without changing index?”
  1. Piotr KrukowieckiApr 24, 2019
  2. Junio C HamanoApr 24, 2019
  3. Piotr KrukowieckiApr 24, 2019
  4. Philip OakleyApr 24, 2019
  5. Sitaram ChamartyApr 25, 2019
  6. Junio C HamanoApr 25, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.