{"thread":{"id":"63482","subject":"Feature request: make reset --hard add something to the reflog","startedAt":"2025-05-19T19:45:59Z","lastAt":"2025-05-19T21:35:21Z","messageCount":4,"participants":["Josh Bleecher Snyder","brian m. carlson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"518449","messageId":"CAFAcib_PV4EB-i4PUmTxCx_6LX=8aWDNT_ZPrN0-EDsRwRfi4g@mail.gmail.com","threadId":"63482","inReplyTo":null,"subject":"Feature request: make reset --hard add something to the reflog","fromName":"Josh Bleecher Snyder","fromEmail":"josharian@gmail.com","sentAt":"2025-05-19T19:45:21Z","receivedAt":"2025-05-19T19:45:59Z","isPatch":false,"sender":{"key":"josharian@gmail.com","avatar":"https://gravatar.com/avatar/df58f649b62f4d66e2e635810212cb54403228630fabfa080eb5847a6f4cc01b?d=mp&s=160"},"body":"Hi!\n\nA feature request:\n\nI git reset --hard a lot. Every once in a while, it hurts, just\ninfrequently enough that I forget the pain and do it again.\n\nI wish that git reset --hard would silently stash, add to reflog,\nstash drop (or the moral equivalent) and then do the reset. That way I\ncould always recover my state post-facto.\n\nThanks,\nJosh\n"},{"id":"518450","messageId":"aCuMshOaqcuwMCpG@tapette.crustytoothpaste.net","threadId":"63482","inReplyTo":"CAFAcib_PV4EB-i4PUmTxCx_6LX=8aWDNT_ZPrN0-EDsRwRfi4g@mail.gmail.com","subject":"Re: Feature request: make reset --hard add something to the reflog","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-05-19T19:55:30Z","receivedAt":"2025-05-19T19:55:38Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-05-19 at 19:45:21, Josh Bleecher Snyder wrote:\n> Hi!\n> \n> A feature request:\n> \n> I git reset --hard a lot. Every once in a while, it hurts, just\n> infrequently enough that I forget the pain and do it again.\n> \n> I wish that git reset --hard would silently stash, add to reflog,\n> stash drop (or the moral equivalent) and then do the reset. That way I\n> could always recover my state post-facto.\n\nI don't know if we want this by default (although I could be convinced\nthat we do), but I think this would actually be a great feature to add\nvia a config option.  You are not the only person who has accidentally\ndestroyed data with `git reset --hard` by any stretch of the\nimagination[0] and this would make that much less painful.\n\nI'm not going to commit to implementing it (although I might do so at\nsome point), but if someone else (or you) wants to do so, I'm sure it\nwould be quite welcome.\n\n[0] I've been contributing to Git for at least seven years and I still\noccasionally lose data (temporarily or permanently) this way.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\n"},{"id":"518452","messageId":"xmqqjz6cmgt4.fsf@gitster.g","threadId":"63482","inReplyTo":"aCuMshOaqcuwMCpG@tapette.crustytoothpaste.net","subject":"Re: Feature request: make reset --hard add something to the reflog","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-19T21:28:07Z","receivedAt":"2025-05-19T21:28:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> I don't know if we want this by default (although I could be convinced\n> that we do), but I think this would actually be a great feature to add\n> via a config option.  You are not the only person who has accidentally\n> destroyed data with `git reset --hard` by any stretch of the\n> imagination[0] and this would make that much less painful.\n\nI do not offhand have a strong objection for the _feature_, but if\nthe implementation uses the default \"stash\", that is a bit\nworrysome, as anybody, even a script, using \"reset --hard\" would add\na new stash entry, shifting the end-user's expectation of what the\nNth stash entry records behind user's back.\n\nDoesn't \"reset --hard\" add record to the reflog already, by the way?\nI agree that a way to recover the local modifications that \"reset\n--hard\" is designed to get rid of is a good addition.  I just do not\nknow what the best vehicle to store the local modifications is.\n\n"},{"id":"518453","messageId":"aCukFlfmQcxRSqGz@tapette.crustytoothpaste.net","threadId":"63482","inReplyTo":"xmqqjz6cmgt4.fsf@gitster.g","subject":"Re: Feature request: make reset --hard add something to the reflog","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-05-19T21:35:18Z","receivedAt":"2025-05-19T21:35:21Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-05-19 at 21:28:07, Junio C Hamano wrote:\n> I do not offhand have a strong objection for the _feature_, but if\n> the implementation uses the default \"stash\", that is a bit\n> worrysome, as anybody, even a script, using \"reset --hard\" would add\n> a new stash entry, shifting the end-user's expectation of what the\n> Nth stash entry records behind user's back.\n\nYes, this would need to live under a different ref.  We could use the\nsame stash machinery, though, with a small refactor.\n\n> Doesn't \"reset --hard\" add record to the reflog already, by the way?\n> I agree that a way to recover the local modifications that \"reset\n> --hard\" is designed to get rid of is a good addition.  I just do not\n> know what the best vehicle to store the local modifications is.\n\nIt does, at least when it changes HEAD.  But it doesn't preserve the\nlocal modifications anywhere, which is really the request that's being\nmade.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\n"}]}