36

Is there any way to undo discard changes in GitHub Desktop, after the Undo button has disappeared?

enter image description here

I am talking about GitHub Desktop's undo feature, not git in general.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • 2
    @TheGeorgeous Thanks, if I use Git Shell, which command should I run? – Franck Dernoncourt Feb 22 '16 at 23:20
  • 6
    You can check recycle-bin once.Sometimes discard file are there in recycle bin and you can restore the same but remember the version you have discarded will only appear. If you have done changes after discarding that will not merge into it. – Vartika Gupta Apr 26 '18 at 06:33

12 Answers12

64

As of 5/8/18, and if you're using the latest version of github desktop or github desktop beta, uncommitted discarded changes are now copied over as new files and put into your trash/recycling bin.

This is what the current prompt looks like:

enter image description here

chrismarx
  • 11,488
  • 9
  • 84
  • 97
43

First of all, Don't Close the VS Code.

Then open all the Files Where you have done Discard Changes.

Press Ctrl+z for Undo & CTRL+S for saving the changes.

It's worked for me.

Ramananda Kairi
  • 431
  • 4
  • 2
15

You can find those discarded files in the recycle-bin.

Tharindu
  • 386
  • 3
  • 17
14

when you're using VS Code, don't close it, go to the file you discared the changes, right click on it, and go to "Open Timeline" and there you'll find all the changes you made on that file, then you can easily get back your last changes :)

Sofiane
  • 473
  • 1
  • 6
  • 13
9

GitHub Desktop Menus -> Repository / Restore Discarded changes

minhbang
  • 123
  • 3
2

Emailed the Github support team and was told that after this option disappears, there is no other way to Undo the change. They may implement this feature at a future time.

azam
  • 442
  • 4
  • 9
2

I'm using Github Desktop for Windows v2.1.0 and I can confirm the trash/recycling bin doesn't exist any more. I'm using Windows 10.

In my case, the discarded change I wanted to undo was a deleted folder.

What solved it for me was to open the parent folder in Windows Explorer and do ctrl+z. This restored my deleted folder.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Hugo Nava Kopp
  • 2,906
  • 2
  • 23
  • 41
1

I got he same situation, just went to the Bin and the files were there. Just needed to replace the code manually again. My machine: Mac.

Harol
  • 93
  • 1
  • 4
  • [windows OS] you can simply restore from the recycle bin. and replace the existing old version – Irshad Dec 21 '22 at 08:08
0

The discarded change is sent to the trash as a new file, with some variation of the original file's name. You can copy and paste the file in the trash to the original file.

For example: I discarded a change to package.json, and the resulting file in the trash was named package 16-36-10-974.json. This file contained the original contents of the file before I discarded it. I copied the contents from package 16-36-10-974.json to package.json, and that's how I got the discarded changes back.

(not sure where the numbers in the file name come from)

Dave B.
  • 159
  • 1
  • 3
0

I had this issue and it appeared that there was no way to restore these files using GitHub Desktop, my files were hosted on one of our servers but for some reason GitHub Desktop didn't move the files to the recycle bin as stated. Thankfully the server was backed up and I was able to restore the files that way.

AMouat
  • 685
  • 15
  • 27
0

I used Recuva and it worked.

Just install the app and select the folder that you need to recover, wait 2 mins

m_rd_n
  • 175
  • 2
  • 11
-1

You need to recover those files from the git repo

git fsck --unreachable --no-reflogs --no-cache HEAD

Or check it out this one:- restoring lost commits

akshay_rahar
  • 1,661
  • 2
  • 18
  • 20
  • This only applies to files that actually were committed, in this case, we're looking for files that were never staged or commited – chrismarx Jun 06 '18 at 16:36