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

Re: Bug report: `git restore --source --staged` deals poorly with sparse-checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 6, 2022, 19:30 UTC
Message-ID
<xmqqv8owkaww.fsf@gitster.g>
In-Reply-To
<96c4f52e-bc66-f4ee-f4f6-d22da579858e@github.com>
Victoria Dye <vdye@github.com> writes:
Show 6 quoted lines
>> Restoring only into the index (as I think `git restore --staged` is supposed
>> to do) is weird. 
>
> 'git restore --staged' is intended to restore to both the worktree and index
> (per 183fb44fd2 (restore: add --worktree and --staged, 2019-04-25)). The bug
> you've identified is that it's not restoring to the worktree.

I think you misread 183fb44fd2, which says --staged is to restore the contents in the index and --worktree is to restore the contents in the working tree, and both of them can be used at the same time to affect both destinations. As gitcli(7) says, --staged here is a synonym to --cached here and should not touch the working tree.

Having needless synonym may be a source of confusion, so we may want to straighten out the UI a bit around here, but that is a separate topic.

Thanks.
Previous: Elijah NewrenNext: Junio C Hamano
Message 10 of 12 in “Bug report: `git restore --source --staged` deals poorly with sparse-checkout”
  1. Glen ChooOct 3, 2022
  2. Victoria DyeOct 4, 2022
  3. Victoria DyeOct 4, 2022
  4. Martin von ZweigbergkOct 5, 2022
  5. Elijah NewrenOct 5, 2022
  6. Martin von ZweigbergkOct 5, 2022
  7. Elijah NewrenOct 6, 2022
  8. Victoria DyeOct 5, 2022
  9. Elijah NewrenOct 5, 2022
  10. Junio C HamanoOct 6, 2022
  11. Junio C HamanoOct 6, 2022
  12. Elijah NewrenOct 5, 2022

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.