Undo 'Discard chunk'

git

#1

Is there a way to undo the effects of the "Discard chunk" button in a git diff window?

I found it is too easy to click one these buttons by mistake while reviewing changes. Without warning, several lines of your carefully crafted code seems to be gone from editor, no longer present in your saved file, and were never in your repo in the first place (as you were just about to commit). Surely there should be a way to undo this?!

Thank you!


#2

Looking around for solutions, it seems like the solution (at least for GitHub desktop) was to add a confirmation step (the thread also links out to some possibilities for trying to get the changes back, but they're a bit beyond my personal level of Git-fu):