【问题标题】:how to revert TILL specific commit in git [duplicate]如何在git中恢复直到特定的提交[重复]
【发布时间】:2016-04-20 17:37:15
【问题描述】:

我想恢复 TILL specificgit

中的提交

我在 git 中做了 3 次提交

  • 第一次提交 > 1:am
  • 第二次提交 > 2:am
  • 第三次提交 > 3:am

现在我想恢复直接到这个特定的第一次提交!

【问题讨论】:

    标签: git git-commit git-reset git-revert


    【解决方案1】:

    您可以这样做以从历史记录中完全删除不需要的提交:

    $ git reset --hard HEAD^^^
    

    但是如果你想保留历史记录,你应该使用git-revert:

    $ git revert <sha1-of-3rd-commit> <sha1-of-2nd-commit>
    

    这将应用恢复旧提交的新提交。

    【讨论】:

      猜你喜欢
      • 2017-05-16
      • 2019-01-12
      • 2023-04-03
      • 2011-10-11
      • 2011-04-08
      • 2014-01-04
      • 2021-04-13
      • 2018-11-10
      • 2018-10-17
      相关资源
      最近更新 更多