在GitHub for Windows中恢复此提交并回滚此提交的含义是什么?

Zin*_*gam 45 github rollback revert github-for-windows

Github for Windows将这两个命令描述为:

  1. revert this commit - 创建一个新的提交,以恢复此提交的更改
  2. rollback this commit - 回滚此提交,保留在此工作目录中提交的所有更改以及稍后的提交

你能解释一下这两个命令的确切含义以及如何使用它们.具体来说,我不明白第二个目的是什么.对我来说完全是无稽之谈.

有可能恢复到先前的提交检查它,如果我不喜欢它,回到最初的位置?

这个gui似乎只是git系统的一小部分,但使用它的适当工作流程是什么?

JB *_*zet 54

假设您的仓库中有一个文件,并且您有以下提交:

commit 1 : the file contains A
commit 2 : the file contains B
commit 3 : the file contains C
Run Code Online (Sandbox Code Playgroud)

如果你执行revert commit 3,你将在repo中有这个:

commit 1 : the file contains A
commit 2 : the file contains B
commit 3 : the file contains C
commit 4 : the file contains B
Run Code Online (Sandbox Code Playgroud)

并且工作副本中的文件也将包含B.

如果你执行回滚,你将在回购中有这个:

commit 1 : the file contains A
commit 2 : the file contains B
Run Code Online (Sandbox Code Playgroud)

并且工作副本中的文件将保持不变.因此,该文件将包含C.例如,它允许您修复一个小错误并再次提交.

  • 值得注意的是[`git reset --hard <old-commit-id>`](http://git-scm.com/docs/git-reset)会将repo和工作副本回滚到``提供old-commit-id`.而使用`--soft`选项只会更改HEAD并保持工作副本不变. (4认同)
  • 第二个命令只是移动`HEAD`,所以你可以解释它. (2认同)

Von*_*onC 12

有可能恢复到先前的提交检查它,如果我不喜欢它,回到最初的位置?

现在(2013年3月),使用GitHub for Windows,您可以撤消回滚而无需键入任何git命令:

请参阅" GitHub for Windows中的撤消按钮 "

我们为Discards,Commits,Rollbacks和Merges添加了Undo支持:

撤消按钮