ramin_hal9001,
@ramin_hal9001@emacs.ch avatar

is too easy to use sometimes: almost lost an important bug fix to a hard reset

I was trying to reset just one file, for that you press X f but I absentmindedly pushed X h instead which deleted all changes. Fortunately saved me, I was able to remember all of the files I had changed, visit each of those buffers and press C-/ (undo) in each of them to recover my work. The correct copy of my files were on the Undo stack. I can see why some people love those backup files with the tilde characters at the end of the file name.

But then again, , or rather was the problem to begin with. Is there any way to configure it to ask for confirmation before doing a hard reset?

ctietze,
@ctietze@mastodon.social avatar

@ramin_hal9001 There's always some way. Fromj brute force overwriting or disabling the function to writing a Magit extension. But there's no built in toggle to enable 'safe mode'.

Not sure how far you want to take this. An elegant implementation would advice-add all dangerous operations with a confirmation yes-or-no/y-or-n question, maybe.

janneke,
@janneke@todon.nl avatar

@ramin_hal9001 Are you sure, you're sure?

Asking for confirmation is a terrible UX, IMHO; you'll get so accustomed to it that you'll click/type that away automatically after a while.

There's always the reflog, right?

ramin_hal9001,
@ramin_hal9001@emacs.ch avatar

> "There's always the reflog, right?"

@janneke in this case I pressed reset before adding things to the current commit so it was not in the reflog as the bug fixes had never been added to a commit, not even a staging commit. What Magit hard reset does is resets to the commit that you select, but first you choose if you want only one file, or if you want to reset all files. That is the difference between hard and soft reset.

It is something I do not very often, so I don't think I would get used to just pressing "yes" reflexively. The problem here was I didn't realize I had pressed X h instead of X f until after I selected the reset commit and all my changes suddenly dissapeared.

janneke,
@janneke@todon.nl avatar

@ramin_hal9001 Ah scary...but then all the changes are still in your buffers, right?

ramin_hal9001,
@ramin_hal9001@emacs.ch avatar

> "Ah scary...but then all the changes are still in your buffers, right?"

@janneke yes and no. Magit automatically updates your buffers whenever the HEAD changes (including after a hard reset). But fortunately the bug fixes were in the undo history, so yes, they were in the buffers and I got them back.

janneke,
@janneke@todon.nl avatar

@ramin_hal9001 Ah right, magit enabled this unbelievably evil magic "feature" by default; I have

(setq magit-auto-revert-mode nil)

it cost me once too. How anyone could ever think this is a good idea, esp. as a default, is beyond me.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • emacs
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • anitta
  • ethstaker
  • provamag3
  • cisconetworking
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • modclub
  • megavids
  • normalnudes
  • Leos
  • JUstTest
  • lostlight
  • All magazines