git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Feature request: make reset --hard add something to the reflog
@ 2025-05-19 19:45 Josh Bleecher Snyder
  2025-05-19 19:55 ` brian m. carlson
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Bleecher Snyder @ 2025-05-19 19:45 UTC (permalink / raw)
  To: Git Mailing List

Hi!

A feature request:

I git reset --hard a lot. Every once in a while, it hurts, just
infrequently enough that I forget the pain and do it again.

I wish that git reset --hard would silently stash, add to reflog,
stash drop (or the moral equivalent) and then do the reset. That way I
could always recover my state post-facto.

Thanks,
Josh

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

* Re: Feature request: make reset --hard add something to the reflog
  2025-05-19 19:45 Feature request: make reset --hard add something to the reflog Josh Bleecher Snyder
@ 2025-05-19 19:55 ` brian m. carlson
  2025-05-19 21:28   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: brian m. carlson @ 2025-05-19 19:55 UTC (permalink / raw)
  To: Josh Bleecher Snyder; +Cc: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On 2025-05-19 at 19:45:21, Josh Bleecher Snyder wrote:
> Hi!
> 
> A feature request:
> 
> I git reset --hard a lot. Every once in a while, it hurts, just
> infrequently enough that I forget the pain and do it again.
> 
> I wish that git reset --hard would silently stash, add to reflog,
> stash drop (or the moral equivalent) and then do the reset. That way I
> could always recover my state post-facto.

I don't know if we want this by default (although I could be convinced
that we do), but I think this would actually be a great feature to add
via a config option.  You are not the only person who has accidentally
destroyed data with `git reset --hard` by any stretch of the
imagination[0] and this would make that much less painful.

I'm not going to commit to implementing it (although I might do so at
some point), but if someone else (or you) wants to do so, I'm sure it
would be quite welcome.

[0] I've been contributing to Git for at least seven years and I still
occasionally lose data (temporarily or permanently) this way.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]

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

* Re: Feature request: make reset --hard add something to the reflog
  2025-05-19 19:55 ` brian m. carlson
@ 2025-05-19 21:28   ` Junio C Hamano
  2025-05-19 21:35     ` brian m. carlson
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2025-05-19 21:28 UTC (permalink / raw)
  To: brian m. carlson; +Cc: Josh Bleecher Snyder, Git Mailing List

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> I don't know if we want this by default (although I could be convinced
> that we do), but I think this would actually be a great feature to add
> via a config option.  You are not the only person who has accidentally
> destroyed data with `git reset --hard` by any stretch of the
> imagination[0] and this would make that much less painful.

I do not offhand have a strong objection for the _feature_, but if
the implementation uses the default "stash", that is a bit
worrysome, as anybody, even a script, using "reset --hard" would add
a new stash entry, shifting the end-user's expectation of what the
Nth stash entry records behind user's back.

Doesn't "reset --hard" add record to the reflog already, by the way?
I agree that a way to recover the local modifications that "reset
--hard" is designed to get rid of is a good addition.  I just do not
know what the best vehicle to store the local modifications is.


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

* Re: Feature request: make reset --hard add something to the reflog
  2025-05-19 21:28   ` Junio C Hamano
@ 2025-05-19 21:35     ` brian m. carlson
  0 siblings, 0 replies; 4+ messages in thread
From: brian m. carlson @ 2025-05-19 21:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Josh Bleecher Snyder, Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

On 2025-05-19 at 21:28:07, Junio C Hamano wrote:
> I do not offhand have a strong objection for the _feature_, but if
> the implementation uses the default "stash", that is a bit
> worrysome, as anybody, even a script, using "reset --hard" would add
> a new stash entry, shifting the end-user's expectation of what the
> Nth stash entry records behind user's back.

Yes, this would need to live under a different ref.  We could use the
same stash machinery, though, with a small refactor.

> Doesn't "reset --hard" add record to the reflog already, by the way?
> I agree that a way to recover the local modifications that "reset
> --hard" is designed to get rid of is a good addition.  I just do not
> know what the best vehicle to store the local modifications is.

It does, at least when it changes HEAD.  But it doesn't preserve the
local modifications anywhere, which is really the request that's being
made.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]

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

end of thread, other threads:[~2025-05-19 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-19 19:45 Feature request: make reset --hard add something to the reflog Josh Bleecher Snyder
2025-05-19 19:55 ` brian m. carlson
2025-05-19 21:28   ` Junio C Hamano
2025-05-19 21:35     ` brian m. carlson

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).