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