【问题标题】:git revert commit/push but keep changesgit revert 提交/推送但保留更改
【发布时间】:2012-04-28 09:40:57
【问题描述】:

是这样的:

  • 我修改了文件 A 和 B

  • 我只是假设提交并推送 A,但不小心同时提交并推送了 A 和 B

  • 我做了一个“git push old-id:master”,所以在 github 上它显示“Master is now old-id”,其中 old-id 是我之前的最后一次提交,所以我认为它回到了我之前已提交。

问题:

  • 在我的本地,如何撤消具有 A 和 B 的提交,只提交 A,只推送 A?

注意:我确实需要将 A 和 B 的更改保留在我的本地。最终结果应该是:

  • 本地 - 新 A 和新 B
  • Github - 新 A 和旧 B

【问题讨论】:

  • 为什么不直接 checkout 之前的 B 然后提交并推送呢?

标签: git commit revert


【解决方案1】:
$ git reset <old-id>    # Undo the commit after old-id
$ git add A             # stage A for a new commit
$ git commit            # make the new commit
$ git push              # push it

【讨论】:

    猜你喜欢
    • 2018-07-20
    • 2021-09-17
    • 2018-12-07
    • 2014-07-13
    • 1970-01-01
    • 2014-05-14
    • 2017-07-09
    • 2013-02-13
    相关资源
    最近更新 更多