代码之家  ›  专栏  ›  技术社区  ›  aldel

为什么合并这些分支什么都不做?

  •  2
  • aldel  · 技术社区  · 9 年前

    简短版本:

    我有两个不同内容的分支。当我在一个分支中进行另一个分支的合并时,它会显示“已经是最新的”。这怎么可能?

    我现在甚至没有做拉,只是从一个本地分支合并,以保持简单。

    接下来可能会有太多细节。

    我将以一个特定的文件为例。在分支主管中(我正在编辑电子邮件地址和旧提交):

    $ git checkout master
    Switched to branch 'master'
    Your branch is up-to-date with 'origin/master'.
    
    $ git log mde/ss/schools/_clone/segmeta.csv
    commit 9e9ee2b19e7a476f2d61ecff1c5d54634132dd93
    Author: gormleycep <redacted>
    Date:   Mon Nov 23 11:18:41 2015 -0800
    
        Fixes spacing issues in segmeta files (my mistake)
    
    commit 6e341cd2a92a1044c957a7a9631e365a08466440
    Author: gormleycep <redacted>
    Date:   Fri Nov 6 12:36:52 2015 -0800
    
        Updated percent positive tables
    
    commit efc05d8b838fb3e8efdc074b65d1a93046c7e6c9
    Author: Alan deLespinasse <redacted>
    Date:   Tue Aug 11 18:46:42 2015 -0400
    
        Fix missing segmentations in MDE Secondary School reports.
    

    在分支BTP_E2ESCH中:

    $ git checkout BTP_E2ESCH
    Checking out files: 100% (2330/2330), done.
    M       common
    Switched to branch 'BTP_E2ESCH'
    Your branch is up-to-date with 'origin/BTP_E2ESCH'.
    
    $ git log mde/ss/schools/_clone/segmeta.csv
    commit 9367a601eef9a7a8975a0cf22d5b49b163a3710c
    Author: cepbrian <redacted>
    Date:   Fri Nov 13 16:17:49 2015 -0500
    
        trying to add end to end tests.
    
    commit efc05d8b838fb3e8efdc074b65d1a93046c7e6c9
    Author: Alan deLespinasse <redacted>
    Date:   Tue Aug 11 18:46:42 2015 -0400
    
        Fix missing segmentations in MDE Secondary School reports.
    

    11月13日cepbrian所做的更改与11月6日gormleycep所做的相同(两个更改都在文件中添加了相同的两行)。11月23日,gormleycp所做的更改删除了这两行中的空格。两个分支中的文件绝对不同。现在我做到了:

    $ git merge master
    Already up-to-date.
    

    分支BTP_E2ESCH中的文件没有更改。

    这是的输出 gitk --all --date-order mde/ss/schools/_clone/segmeta.csv ,为便于可视化:

    enter image description here

    Git在什么状态下会发生这种情况?

    1 回复  |  直到 9 年前
        1
  •  2
  •   rodrigo    9 年前

    我认为问题是 git log -- <filename> 可能有点 欺骗的 从…起 man git-log :

    [--] ... 仅显示足以解释如何 匹配指定的路径。

    并重定向到 历史简化 有很多细节的部分。。。

    我的意思是,您的分支可能已经合并,但在简化的日志中看不到这一点!

    这最好用一个例子来说明。让我们考虑一下这个存储库:

    A----B----C----M
         \----T----/
    

    在有分支的地方, test 指向 T master 指向 M ,这是一个合并提交。有一个 file 在存储库中,每次提交时都包含以下内容:

    A: 1
    B: 2
    C: 3
    T: ttt
    M: 3
    

    进行合并时 测验 进入 主人 有一个冲突,通过丢弃来自 T .

    现在,如果我从 主人 , git log ,我得到:

    M
    C
    T
    B
    A
    

    但如果我跑了 git log -- file ,我得到:

    C
    B
    A
    

    因为 T M 提交对文件的最终内容没有影响。那是 历史简化 !

    你可以跑步 git log --full-history -- test 要获取所有接触文件的提交:

    M
    C
    T
    B
    A.