【问题标题】:How do I merge two Git branches, with specific commit ids, into one branch?如何将具有特定提交 ID 的两个 Git 分支合并到一个分支中?
【发布时间】:2011-11-02 23:56:45
【问题描述】:

我有两个提交:

[branch]: [commit_id]
justin: 94943b74ba273a9f4009
jzbranch: 6070aada7b8a690d410b

如何将两个分支合并到 jzbranch 中,并解决两者之间的差异?

【问题讨论】:

    标签: git merge commit git-branch git-checkout


    【解决方案1】:

    如何将具有特定提交 ID 的两个 Git 分支合并为一个 分公司?

    git checkout jzbranch
    
    git merge [commit_id] jzbranch
    

    git merge [commit_id] 6070aada7b8a690d410b
    

    因为 git 允许将多个分支/提交合并为一个。

    然后运行git mergetool 或简单的git status(在第二种情况下,您只会看到冲突文件,然后您可以使用您喜欢的任何编辑器打开这些文件)。我更喜欢第二种方式。

    在那之后强制进行新的提交

    【讨论】:

      【解决方案2】:
      1. 查看 jzbranch 分支
        git checkout jzbranch

      2. 在贾斯汀中合并
        git merge justin

      3. 如果有冲突,在git mergetool运行后运行git mergetool,使用git commit提交最终合并。

      【讨论】:

        【解决方案3】:
        git branch newbranch 6070aada7b8a690d410b
        git checkout newbranch
        git merge 94943b74ba273a9f4009
        

        【讨论】:

          猜你喜欢
          • 2011-09-16
          • 2016-03-23
          • 1970-01-01
          • 2012-03-02
          • 2013-11-09
          • 2018-03-12
          • 2012-11-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多