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

如何有效地审查现有的git合并?

  •  0
  • Bruce  · 技术社区  · 12 年前

    我想查看git合并提交,查看已经完成并推送到服务器的合并。

    我的团队最近有几次因为合并失败(暂时)失去了工作。目前还不清楚我们是否执行了错误的合并,或者我们是否在合并期间进行了错误的冲突解决修复。我想仔细观察一下我们的团队合并,以确保一切顺利;但我不知道如何使用git或相关工具来有效地做到这一点。

    我最接近的是“gitk”工具。当我查看该工具中的合并节点时,diff视图似乎显示了所需的信息,但我发现很难快速理解合并结果的特定块是来自父节点a、父节点B还是来自冲突解决修复。(这叫补丁吗?)

    我有一个Beyond Compare的副本,它有一个合并显示模式,但当我用“git mergetool”设置它时,它似乎只想处理当前的合并-我不知道如何从git历史中提取一个。

    请告诉我如何更有效地使用我拥有的工具,和/或我可以使用哪些其他工具来管理这些审查。

    2 回复  |  直到 12 年前
        1
  •  1
  •   Gary Fixler    12 年前

    您可以将合并与任一父项进行比较:

    git diff <1st-parent-hash> <merge-commit-hash>
    git diff <2nd-parent-hash> <merge-commit-hash>
    

    或者使用1st/2nd父语法。如果合并提交为abc123:

    git diff abc123^1 abc123
    git diff abc123^2 abc123
    
        2
  •  1
  •   Jack    12 年前

    我听说Tower很不错。

    您可以使用github的比较功能来比较提交、标记甚至分支。如上所示 GitHub

    Compare View URLs
    
    We wanted Compare View to be something we could link to from external sites and services anytime we were referring to a range of commits in a git repository. As such, we thought it would be worthwhile to document the basic structure of a Compare View URL:
    
        http://github.com/<USER>/<REPO>/compare/[<START>...]<END>
    
    Where <USER> and <REPO> are obvious, and <START> and <END> are branch names, tag names, or commit SHA1s specifying the range of history to compare. If <START> is omitted, the repository's default branch is assumed
    

    至于更有效的分支方法,我建议使用此方法。我曾在几家创业公司工作过——> http://nvie.com/posts/a-successful-git-branching-model/

    推荐文章