自定义 git mergetool 来合并目录

问题描述 投票:0回答:1

我必须编写自定义 GUI git mergetool,它必须立即解决目录中所有(二进制)文件的冲突,因为这些文件具有数据相互依赖性,并且必须确保一致性。所以,我已经配置好了

[mergetool "custommerge"]
    cmd = custommerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    trustExitCode = true

当存在 git 合并冲突并且 mergetool 由

git mergetool -t custommerge dirA/file1
打开时,然后我需要签出目录
dirA
的基础、本地和远程版本快照(例如,进入 tmp 目录)。 git工作树处于合并冲突状态怎么办?

更新:对于我找到的本地和远程版本

git --work-tree /tmp/tmpdir [--ours|--theirs] checkout --theirs ./dirA

那么,现在有一些方法可以找到当前的合并基础。

git mergetool
1个回答
0
投票

对于本地和远程版本都是可以的

git --work-tree /tmp/tmpdir [--ours|--theirs] checkout --theirs ./dirA

注意:当使用 LFS(或任何其他涂抹/清理工具)时,始终签出工作树根目录“./”会更安全,因为签出时会忽略根目录中的

.gitattributes
问题是如何找到正确的基本提交哈希 ID。通过这个答案

https://stackoverflow.com/a/69380610/254109

使用: /dirA

如果它只返回一个提交 ID,则将其用作当前合并冲突的基础。如果它返回更多提交 ID,则合并是递归的,不幸的是,不可能获得中间提交哈希。

© www.soinside.com 2019 - 2024. All rights reserved.