2012-04-17 68 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