git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Request: `git restore $commit $file` shouldn’t override uncommited changes
@ 2021-04-27 17:37 Robin Moussu
  2021-04-27 19:29 ` Johannes Altmanninger
  2021-04-28  7:23 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Robin Moussu @ 2021-04-27 17:37 UTC (permalink / raw)
  To: git

Hello,
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.

I recently discovered that `git restore` was introduced to make file manipulation less confusing than with `git checkout`. I know it was introduced a few years ago, I’m late to the party! I would have expected that the semantic of `git restore` or `git restore $file` would discard all uncommitted changes (you are restoring the file after all), while `git restore $commit $file` would copy the content of said file from another revision only if your don’t have uncommitted changes or to get an error. If it was really what I wanted to do, I would have expected to either do `git restore $file && git restore $commit $file`, directly `git restore --force $commit $file` or something similar.

Is my expectation wrong? Would it be worth considering adding an option in `.gitconfig` to have such behavior?

Sincerely,
Robin.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-28  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 17:37 Request: `git restore $commit $file` shouldn’t override uncommited changes Robin Moussu
2021-04-27 19:29 ` Johannes Altmanninger
2021-04-28  8:35   ` Robin Moussu
2021-04-28  9:10     ` Junio C Hamano
2021-04-28  7:23 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).