Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo "Discard" if not committed

I accidentally clicked Discard while committing my changes. So I discarded the whole file but I wanted to discard only some hunk. But I haven't clicked on Commit, I did Cancel.

But now I cannot see my code in my file.

What can I do to undo the damn discard ?

Thanks in advance

like image 538
BPL Avatar asked Sep 07 '25 14:09

BPL


1 Answers

I know the post is too old but I faced the similar situation and accidentally clicked "Discard" in SourceTree and lost my changes.

Luckily I had the IDE opened, i.e. PHPStorm, at the time. Though it had already refreshed the file I was working on and loaded the old copy after Discard, however, I did "undo" on the working file in editor and it loaded back my changes.

I saved the file and got my lost changes back.

Just wanted to share in case others face the similar situation as mine and want to recover their changes with little presence of mind :D

like image 112
Ghazanfar Mir Avatar answered Sep 10 '25 00:09

Ghazanfar Mir