git 如何撤消 GitHub Desktop 中的放弃更改?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35546133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:56:33  来源:igfitidea点击:

How can I undo discard changes in GitHub Desktop?

gitgithubgithub-desktop

提问by Franck Dernoncourt

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

在撤消按钮消失后,有没有办法撤消GitHub Desktop 中的丢弃更改?

enter image description here

在此处输入图片说明

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

我说的是 GitHub Desktop 的撤消功能,而不是一般的 git。

采纳答案by azam

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.

向 Github 支持团队发送电子邮件,并被告知在此选项消失后,没有其他方法可以撤消更改。他们可能会在将来实现此功能。

回答by chrismarx

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.

截至 2018 年 5 月 8 日,如果您使用的是最新版本的 github 桌面或 github 桌面测试版,未提交的丢弃更改现在将作为新文件复制并放入您的垃圾箱/回收站。

This is what the current prompt looks like:

这是当前提示的样子:

enter image description here

在此处输入图片说明

回答by Tharindu

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

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

回答by minhbang

GitHub Desktop Menus -> Repository / Restore Discarded changes

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

回答by Dave B.

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.jsonto package.json, and that's how I got the discarded changes back.

例如:我放弃了对 的更改package.json,而垃圾箱中的结果文件名为package 16-36-10-974.json。在我丢弃它之前,该文件包含文件的原始内容。我从package 16-36-10-974.jsonto复制了内容package.json,这就是我如何取回丢弃的更改。

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

(不确定文件名中的数字来自哪里)

回答by ASindleMouat

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.

我遇到了这个问题,似乎无法使用 GitHub Desktop 恢复这些文件,我的文件托管在我们的一台服务器上,但由于某种原因,GitHub Desktop 没有按照说明将文件移动到回收站。谢天谢地,服务器已备份,我能够以这种方式恢复文件。

回答by Hugo Nava Kopp

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.

我正在使用 Github Desktop for Windows v2.1.0,我可以确认垃圾箱/回收站不再存在。我正在使用 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.

为我解决的是在 Windows 资源管理器中打开父文件夹并执行 ctrl+z。这恢复了我删除的文件夹。

I hope this is of use for someone.

我希望这对某人有用。

回答by Ramananda Kairi

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

首先,不要关闭VS Code。

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

然后打开所有已完成放弃更改的文件。

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

按 Ctrl+z 撤消,按 CTRL+S 保存更改。

It's worked for me.

它对我有用。

回答by akshay_rahar

You need to recover those files from the git repo

您需要从 git repo 中恢复这些文件

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

Or check it out this one:- restoring lost commits

或者看看这个:- 恢复丢失的提交

回答by Nostalg.io

I recently experienced this same issue.

我最近遇到了同样的问题。

After searching through git login the terminal, I can confirm that my latest commit is gone. Just gone. Along with the code changes. Unless you synced it to a remote server, it's gone for good.

git log终端中搜索后,我可以确认我的最新提交已经消失。刚走了。随着代码的变化。除非你将它同步到远程服务器,否则它就一去不复返了。

Now I will never use Git Desktop again.

现在我再也不会使用 Git 桌面了。