Reputation: 287
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
Upvotes: 27
Views: 30034
Reputation: 57
If you use Visual Code check local history.
Bottom left -> Explorer -> Timeline -> you can see the changes made.
Upvotes: 0
Reputation: 1335
For me I'm using mac when I discard file and I want to get back
I open that file and open with TextEditor.app
on the top bar click File -> Revert To -> Browse All Version...
Select on last save version that you want hope it can save your time.
Upvotes: 34
Reputation: 5684
If you have lost a javascript or template file, there's a chance you will find it in the browser if you were debugging it and haven't reloaded.
Upvotes: 0
Reputation: 17
In Eclipse,
Upvotes: 1
Reputation: 3541
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
Upvotes: 39
Reputation: 37505
There isn't any way to get your changes back via git or sourcetree as of sourcetree 1.8.1 for Mac; see the discussion here:
https://jira.atlassian.com/browse/SRCTREE-2090
(If you login to jira, you can also vote for this to be implemented!)
When I did this, I was able to get the changes back as the file was in my time machine backup.
Upvotes: 1
Reputation: 16946
I don't believe you can do anything. If you didn't commit the changes at any points, there is no way to get them back after you discard them.
Upvotes: 1