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

Re: Request: `git restore $commit $file` shouldn’t override uncommited changes

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 28, 2021, 07:23 UTC
Message-ID
<xmqqbl9yc1o6.fsf@gitster.g>
In-Reply-To
<pYZzGPZTHnJjYBKrUAVGcso74I_xJgfzNpSwDN94fhYcDoOamp62-IFvxVrU056uw0txy3MTHYSwny_II0XY4trSY5_E25q7EXwhNHjy3VY=@pm.me>
Robin Moussu <moussu.robin@pm.me> writes:
Show 7 quoted lines
> That’s the first time I’m interacting with the git community,
> I’m not very familiar with the process. I hope I’m at the right
> place for a feature request.
>
> Currently, I don’t think that it’s possible to get an error when
> copying the content of a file from another revision into your
> working tree if said file has uncommitted changes.

Yes, "git restore <from-where> <pathspec>" is like "I made a mess in the paths <pathspec> in the working tree and I want to start from a known state, so please take the contents for these paths from <from-where> and overwrite the garbage I have in the working tree".

It would be a grave regression to stop overwriting by default, as it misses the entire point of the command.

The same applies to "git checkout <from-where> -- <pathspec>".
Previous: Junio C Hamano
Message 5 of 5 in “Request: `git restore $commit $file` shouldn’t override uncommited changes”
  1. Robin MoussuApr 27, 2021
  2. Johannes AltmanningerApr 27, 2021
  3. Robin MoussuApr 28, 2021
  4. Junio C HamanoApr 28, 2021
  5. Junio C HamanoApr 28, 2021

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.