git TortoiseGit - 恢复?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1335644/
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-10 06:56:38  来源:igfitidea点击:

TortoiseGit - Revert?

gittortoisegit

提问by Goober

I am using TortoiseGit. I want to revert back to a point earlier before i had deleted a few images.

我正在使用 TortoiseGit。我想恢复到我删除一些图像之前的一个点。

How do i do this, the methods of reverting that i have seen are incorrect....

我该怎么做,我看到的恢复方法不正确....

回答by Ryan Kearney

Right click your working directory and select Show Log from the TortoiseGit menu.

右键单击您的工作目录并从 TortoiseGit 菜单中选择显示日志。

After that you can right click previous commits and reset the branch to that commit.

之后,您可以右键单击以前的提交并将分支重置为该提交。

回答by James Lawruk

If you deleted a few files and you have not made a commit yet, Revertwill work just fine. Selecting TortoiseGit -> Revert... will display a window for you to select the files you want restored. Deleted files will show in red.

如果你删除了一些文件并且你还没有提交,Revert就可以正常工作。选择 TortoiseGit -> Revert... 将显示一个窗口供您选择要恢复的文件。删除的文件将显示为红色。

If you already committed the delete, then you can Resetto a commit before you deleted the files. Be warned that if you use reset, you will no longer see in your log the commit(s) after the commit you reset to.

如果您已经提交了删除,那么您可以在删除文件之前重置为提交。请注意,如果您使用重置,您将不再在您的日志中看到您重置后的提交。

If you want to preserve in your log the commit that deleted the files, you can Checkoutthe commit before the delete into a new branch, copy the restored files into a separate folder, switch back to your original branch, then add the files back to your original branch.

如果你想在你的日志中保留删除文件的提交,你可以在删除之前检出提交到一个新的分支,将恢复的文件复制到一个单独的文件夹中,切换回你的原始分支,然后将文件添加回你原来的分支。

回答by Matas Vaitkevicius

  1. Right mouseon a directory or file you are plan on reverting, then Tortoise Git-> Show log.
  1. Right mouse在您计划恢复的目录或文件上,然后Tortoise Git-> Show log

enter image description here

在此处输入图片说明

  1. Select at the top of window revision you want to revert to then at the bottom part of the screen Right mouseon any file and choose Revert to this revision.
  1. 选择要恢复到的窗口修订的顶部,然后在Right mouse任何文件的屏幕底部选择Revert to this revision

enter image description here

在此处输入图片说明

Hope this saves you some time.

希望这可以为您节省一些时间。

回答by Farhan

Git turns out a horrible nightmare when a merge commit occur. A merge often destroy some of the recent commits/changes. Here is a way to revert a merge and recover the changes via TortoiseGit.

当合并提交发生时,Git 变成了一个可怕的噩梦。合并通常会破坏一些最近的提交/更改。这是一种通过 TortoiseGit 恢复合并和恢复更改的方法。

1) Right mouse click at your repo, TortoiseGit->Show Reflog Step 1

1) 在你的 repo 上右击鼠标 TortoiseGit->Show Reflog 第1步

2) Reflog dialog will appear, showing all the recent commits. Right mouse click the Merge commit (the one that caused the problem) and then select the option "Revert change by this commit" -> Parent 2 as shown in the image.| Step 2

2) 将出现 Reflog 对话框,显示所有最近的提交。鼠标右键单击合并提交(导致问题的提交),然后选择选项“通过此提交还原更改”-> 父 2,如图所示。| 第2步

This will recover all the missing changes to your local repository, commit and push and you should be good to go.

这会将所有丢失的更改恢复到您的本地存储库、提交和推送,您应该很高兴。