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

git restore --staged --worktree does not restore the index (Git 2.24.1)

From
HBHenré Botha <henrebotha@gmail.com>
Date
Dec 16, 2019, 10:51 UTC
Message-ID
<CAHbriemxQLVFQw9pTb37JmoD2QVqLcfgY43qFg4Ab8prrBSkuw@mail.gmail.com>
git help restore says:
    The command can also be used to restore the content in the index
with --staged, or restore both the working tree and the index with
--staged --worktree.
However, this doesn't seem to work as advertised:
    $ mkdir foo; cd foo; git init
    $ touch a b; git add a b && git commit -m "Initial commit"
    $ echo "Foo" > a; echo "Bar" > b
    $ git add a
    $ git status --short
    M  a
     M b
    $ git restore --staged --worktree .
    $ git status --short
    M  a

I'm not sure whether I expect 'a' to be empty at the end of this sequence, but I definitely expect it not to contain staged changes.

Next: Phillip Wood
Message 1 of 2 in “git restore --staged --worktree does not restore the index (Git 2.24.1)”
  1. Henré BothaDec 16, 2019
  2. Phillip WoodDec 16, 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.