2012-04-17 75 views
21

它是这样的:混帐复归提交/推而保留的更改

  • 我有文件A和B,我修改

  • 我只是想承诺,推动A,却意外承诺并推A和B两者

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

问:

  • 在我的地方,我如何取消提交具有A和B,只有承诺,只有推?

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

  • 地方 - 新A和新型B
  • Github上 - 新一老乙
+1

为什么不签之前的B,然后提交,并将它推? – 2012-04-17 03:29:59

+0

那会工作:) – 2012-04-17 03:41:55

回答

37
$ 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