简体   繁体   English

如何撤消重置(Git / TortoiseGit)?

[英]How to undo a reset (Git / TortoiseGit)?

I'm currently (the only one) working on a local repository being pushed remotely to my GitHub accounts.我目前(唯一一个)正在处理一个本地存储库,该存储库被远程推送到我的 GitHub 帐户。 Today I could not find anything about the new code I wrote yesterday night so I was wondering what could went wrong or if I've done some mistake accidentally.今天我找不到关于我昨天晚上写的新代码的任何信息,所以我想知道可能出了什么问题,或者我是否不小心犯了一些错误。

Now I'm inspecting my Reflog (using Tortoise Git).现在我正在检查我的 Reflog(使用 Tortoise Git)。 As you can see from my Reflog Screenshot , a RESET occurred, which could explain why I "lost" the code.正如您从我的Reflog Screenshot中看到的那样,发生了 RESET,这可以解释为什么我“丢失”了代码。 My question would be: is it possible to undo this reset in such a way to get all files as they were the moment right before resetting?我的问题是:是否可以撤消此重置以获取所有文件,就像它们在重置前的那一刻一样? If not possible, since everything is quite recent, is there any another way to achieve the same result?如果不可能,因为一切都是最近的,有没有其他方法可以达到相同的结果?

Thank you very much for your help!非常感谢您的帮助!

Undoing a reset highly depends on the type of reset and the working tree state.撤消重置很大程度上取决于重置的类型和工作树 state。

When you performed a hard reset and you had uncommitted changes in your working tree, then these uncommitted changes are lost (unless you have backupped them before).当您执行硬重置并且您的工作树中有未提交的更改时,这些未提交的更改将丢失(除非您之前已备份它们)。

When you had no uncommitted changes, you can easily open the RefLog dialog, select the last commit/entry before the reset and open the context menu.当您没有未提交的更改时,您可以轻松打开 RefLog 对话框,select 重置前的最后一个提交/条目并打开上下文菜单。 Here you can create a new branch that then points to the state of the repository (index) before the reset.在这里,您可以创建一个新分支,然后在重置之前指向存储库(索引)的 state。 When you now open this branch in the log dialog, you can rebase it onto you old branch or cherry pick commits or what you would like to do.当您现在在日志对话框中打开此分支时,您可以将其重新定位到您的旧分支或樱桃选择提交或您想做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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