简体   繁体   中英

How can I undo discard changes in GitHub Desktop?

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

在此处输入图像描述

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

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:

在此处输入图片说明

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.

您可以在回收站中找到那些丢弃的文件。

GitHub 桌面菜单 -> 存储库/恢复丢弃的更改

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.

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

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)

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.

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.

I used Recuva and it worked.

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

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.

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:)

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

在此处输入图片说明

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

There are many ways to do it as well which are not described here as well.

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

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM