如何验证git合并不包含额外的更改? [英] How to verify a git merge contains no extra changes?

查看:218
本文介绍了如何验证git合并不包含额外的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git中,如何验证合并上游主控提交没有包含任何额外差异?假设我想验证这个人除了实际合并来自上游主分支的变更之外没有做任何'偷偷摸摸'的事情。



我想验证唯一的差异来自他们提交的其他提交;他们没有执行'邪恶合并'



有没有办法验证合并步骤中没有进行其他更改?

或者更好:向我展示潜在的'邪恶合并'差异所以我可以看到自己可能做了哪些额外的工作?



示例场景:

  P1 --- P2 P3 --- P4 --- P5 --- P6 
/ \ / / \
A --- B --- C-- -D - E -------- F --------- G master
\ /
C1 --- C2

P1 ..P2:第一个拉取请求
C1..C2:我的工作分支
P3..P4:在
之间完成的更多工作P5:在主分支中合并的提交更改
P6:更多的常规工作




  1. 有人向我的回购 P1..P2

  2. 拉动请求很棒,一个d我将它合并( E

  3. 我做了一些进一步的开发( C1..C2 ),将我自己的分支集成到master( F ),并发布

  4. 另一个人做了更多的工作( P3..P4

  5. 它们将上游更改合并到本地回购库( P5 )进行更多更改( P6 ),并发送第二个请求

  6. 我可以验证他们是否'在合并过程中潜入任何额外差异( P5 )?


解决方案

你可以检查git merge commit是否包含任何其他更改,方法是执行差异diff。这是一种方法。

  P1 --- P2 P3 --- P4 --- P5 --- P6 
/ \ / / \
A --- B --- C --- D - E -------- F --------- G master
\ /
C1 --- C2




  1. 计算原共同父元 E 与合并前的主分支提交之间的主分支中所有变更的差异, F <


    git diff EF> master_changes_to_merge.txt


  2. >
  3. 计算'merge in master'commit中变化的所有内容的差异, P5


    git diff P4 P5> master_changes_actually_merged.txt


  4. / b>


    diff master_changes_to_merge.txt master_changes_actually_merged.txt


  5. ol>

    如果第3步显示没有输出,应该没有恶意合并更改。


    In git, how do I verify that a merge upstream master commit does not contain any additional diffs? Say I want to verify that the person didn't do anything 'sneaky' besides actually merge the changes from the upstream master branch.

    I want to verify that the only diffs come from the other commits they made; that they did not perform an 'evil merge'.

    Is there a way to verify that no additional changes were made during the merge step?
    Or better yet: show me the potential 'evil merge' diffs so I can see for myself what extra work might have been done?

    Example scenario:

              P1---P2   P3---P4---P5---P6
             /       \  /        /       \
        A---B---C---D--E--------F---------G master
                        \      /
                         C1---C2
    
    P1..P2: First pull request
    C1..C2: My working branch
    P3..P4: More work done inbetween
    P5: The commit that merges in master branch changes
    P6: More regular work
    

    1. Someone sends a pull request to my repo (P1..P2)
    2. The pull request is fantastic, and I merge it (E)
    3. I do some further development (C1..C2), integrate my own branch to master (F), and publish
    4. The other person has done more work in the meantime (P3..P4)
    5. They merge upstream changes into their local repo (P5), makes more changes (P6), and send a second pull request
    6. Can I verify that they didn't sneak in any extra diffs during the merge (P5)?

    解决方案

    You can check whether a git merge commit contains any other changes by doing a diff of diffs. Here's one way.

              P1---P2   P3---P4---P5---P6
             /       \  /        /       \
        A---B---C---D--E--------F---------G master
                        \      /
                         C1---C2
    

    1. Calculate the diff of all changes in the master branch between the original common parent E and the master branch commit just before the merge, F:

      git diff E F > master_changes_to_merge.txt

    2. Calculate a diff of everything changed in the 'merge in master' commit, P5

      git diff P4 P5 > master_changes_actually_merged.txt

    3. Diff those:

      diff master_changes_to_merge.txt master_changes_actually_merged.txt

    If step 3 shows no output, there should be no evil merge changes.

    这篇关于如何验证git合并不包含额外的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆