【问题标题】:how to pull out a commit from git history?如何从 git 历史中提取提交?
【发布时间】:2014-11-01 08:40:36
【问题描述】:

我很困惑如何解决我的问题。 我的 git 历史是这样的(提交 id):

commit: f8ae2 -> parent: 71bf9 
commit: 71bf9 -> parent: f67c0 
commit: f67c0 -> parent: 5b18a 
commit: 5b18a -> parent: 9e111 
commit: 9e111 -> parent: ce53b
commit: ce53b -> parents: f1b1a, 2055e
commit: f1b1a -> parent: 2055e
commit: 2055e

由于我是唯一一个在分支上工作的人 - 并且仍未合并到上游 - 我想从历史记录中拉出或删除 commit: f1b1a。因此,我希望 commit: ce53b 只有 2055e 作为其父级。

我该怎么办?任何建议将不胜感激。谢谢。

【问题讨论】:

    标签: git git-rebase git-revert


    【解决方案1】:

    您可以为此使用交互式变基:运行

    git rebase -i --onto 2055e 2055e
    

    然后删除您不想在历史记录中出现的每一行。

    【讨论】:

    • 我发现cherry-pick 也很有趣。 gitready.com/intermediate/2009/03/04/…
    • @Hesam cherry-pick 会将提交提交到另一个分支.. 但在这种情况下会成功吗?
    • @VinayVeluri,我首先测试了 cherrey-pick,但是是的,你是对的,它没有帮助我,然后使用了 Nils 的建议。 VIP打开,我删除了我想要的行。尼尔斯的建议就是答案。
    猜你喜欢
    • 2015-09-02
    • 2014-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 2011-01-19
    • 2013-08-03
    相关资源
    最近更新 更多