【发布时间】:2019-08-31 15:02:19
【问题描述】:
我想知道发生了什么。我创建了一个 HTML 文件并在其中放入了一些行
this is first line
this is second line
this is third line
this is fourth line
并在每行之后分别提交,如提交 a、提交 b、提交 c、提交 d。
现在我执行了一个还原到提交 c,但它抛出了一个错误:
could not revert 82b69e5... c
hint: after resolving the conflicts, mark the corrected paths <br>
hint: with 'git add <paths>' or 'git rm <paths>' <br>
hint: and commit the result with 'git commit'<br>
我想知道 git-revert 是如何工作的。我知道类似“撤消提交并添加新提交”之类的东西,但不知道如何成功使用它。
【问题讨论】:
-
我很确定 Stack Overflow 上的重复项已经回答了这个问题。
-
喜欢回答 here,
git revert通过进行另一个删除这些更改的提交来“撤消”一个提交引入的更改。如果原始提交添加了一行,则还原提交将删除该行。如果原始提交删除了一行,则还原提交会将其放回原处。如果原始提交更改了一行,则还原将尝试撤消这些更改。 -
您收到错误消息的原因是因为冲突,
c提交引入的更改与其他提交中引入的更改过于接近,因此 git 通过要求您“解决冲突”,本质上是找出正确的结果应该是什么。 -
@LasseVågsætherKarlsen 你的建议对我有用,可能我没有留下太多空间。
标签: git github revert git-revert