2012-04-03 41 views

回答

2

如果你已經推變爲遙控器,你可以使用:

$ git revert <hash of commit b> 

,創建一個新的提交d去除的變化犯b

+0

酷!它保存提交'C'? – 2012-04-03 20:42:57

+0

是的,:) – stewe 2012-04-03 20:46:07

+0

字面意思是它創建一個新的提交,它是b的* inverse *,並將它提交到c之上。它應該推出任何提交到b的東西,並且留下一些歷史錯誤和清理的痕跡,有些人不喜歡,但我真的這樣做。 – 2012-04-03 20:48:32

0

如果您只需要從頭起一個承諾,你可以使用摘櫻桃在不同的分支帶來只是犯了:

$ git checkout -b working 
$ git reset --hard <hash of the commit `a`> 
$ git cherry-pick <hash of the commit `c`> 

硬復位將工作副本更改回到提交時的狀態,然後櫻桃選擇將在提交c中引入的更改直接應用於工作副本的頂部。

0

的幫助git的變基約會談確切的情況!檢查出來:

A range of commits could also be removed with rebase. If we have the 
    following situation: 

      E---F---G---H---I---J topicA 

    then the command 

     git rebase --onto topicA~5 topicA~3 topicA 

    would result in the removal of commits F and G: 

      E---H'---I'---J' topicA 

    This is useful if F and G were flawed in some way, or should not be 
    part of topicA. Note that the argument to --onto and the <upstream> 
    parameter can be any valid commit-ish. 
+0

'topicA'是分支名稱嗎? – 2012-04-03 20:51:23

+0

是的。在這個例子中,topicA〜5可以是任何提交;這在你的問題中是'c'。 topicA〜3將是'a' – GoZoner 2012-04-03 20:58:23