简体   繁体   English

如何使用 TortoiseGit 还原特定提交?

[英]How to revert a particular commit using TortoiseGit?

I have a repo named messaging parent.我有一个名为 message parent 的 repo。 Initially the version of this repo was 1.1.0 .最初这个 repo 的版本是 1.1.0 。 Then it was upgraded to 1.2.0 with some changes.然后它升级到 1.2.0 并进行了一些更改。 Now we have pushed some more changes on top of this version.现在,我们在此版本之上推送了更多更改。 For some reason the commit where the version was changed from 1.1.0 to 1.2.0 with some changes has to be reverted.出于某种原因,必须还原版本从 1.1.0 更改为 1.2.0 并进行一些更改的提交。 Is it possible to revert that commit but still keep our latest changes which we pushed on top of that?是否可以恢复该提交,但仍保留我们在此之上推送的最新更改? There are no conflicting files in both the commits两个提交中没有冲突的文件

yes, you can: TortoiseGit -> Show Log , then select this commit, press right button and select from context menu: Revert Change by this commit .是的,您可以: TortoiseGit -> Show Log ,然后选择此提交,按右键并从上下文菜单中选择: Revert Change by this commit

在此处输入图片说明

New commit will be created, which revert this commit, all other commits are staying untouched.将创建新提交,还原此提交,所有其他提交保持不变。

From atlassian git revert :从 atlassian git revert

The git revert command undoes a committed snapshot. git revert 命令撤消已提交的快照。 But, instead of removing the commit from the project history, it figures out how to undo the changes introduced by the commit and appends a new commit with the resulting content.但是,它不是从项目历史中删除提交,而是弄清楚如何撤消由提交引入的更改,并附加一个带有结果内容的新提交。 This prevents Git from losing history, which is important for the integrity of your revision history and for reliable collaboration.这可以防止 Git 丢失历史记录,这对于您的修订历史记录的完整性和可靠的协作非常重要。

Right click on the repo -> tortoise git -> show logs -> select the commit that you want to revert -> right click -> select the option stating revert changes from this commit -> proceed with the steps -> Do a commit and then push.右键单击 repo -> tortoise git -> 显示日志 -> 选择要还原的提交 -> 右键单击​​ -> 选择声明从该提交还原更改的选项 -> 继续执行步骤 -> 执行提交和然后推。

you will still see the commit in logs but don't worry about that as that's just for history您仍然会在日志中看到提交,但不要担心,因为这只是历史记录

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

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