告诉 git 不要合并二进制文件而是选择

发布于 2024-09-03 08:07:44 字数 174 浏览 1 评论 0原文

当二进制文件、swf、jar 和 flv 在本地更改时,我尝试引入更改,git 会尝试合并它们并报告冲突。

然后,我分支到一个临时分支,并提交本地更改的二进制文件,并在拉取后使用递归策略将它们合并回来。 ——工作量太大了。

有没有办法告诉 git,不要尝试合并二进制文件并询问我使用这些版本中的哪一个。

When the binary files, swfs, jars and flvs are changed locally, and I try to pull in changes, git tries to merge them and reports conflict.

And then, I branch to a temporary branch, and commit the local changed binary files, and merge them back after the pull with recursive theirs strategy. -- Too much work.

Is there a way to tell git, not to attempt merging binary files and ask me which one of these versions to use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许久 2024-09-10 08:07:45

您可以在 .gitattributes 文件中设置合并驱动器(仅适用于给定子树,仅适用于某些文件类型)

请参阅这个问题(或这个)。

# choose the name of the merge driver to be use for all jar files
echo *.jar merge=keepTheir > dirWithJarFiles\.gitattributes

在 Git 存储库的配置中声明您的合并驱动程序:

git config merge.keepTheir.name "always keep their during merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"

或者

git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"
[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B

我给出的示例不会要求您进行选择,但在合并时将始终保留“我的”(或“您的”)版本。
但是您可以调整此合并驱动程序执行的脚本来询问您问题,然后将您的选择应用于所有合并。

You could set up a merge drive in a .gitattributes file (only for a given subtree, only for some file types)

See this question for instance (or this one).

# choose the name of the merge driver to be use for all jar files
echo *.jar merge=keepTheir > dirWithJarFiles\.gitattributes

Declare your merge driver in the config of the Git repo:

git config merge.keepTheir.name "always keep their during merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"

or

git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"
[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B

The example I give don't ask you for a choice but will always keep "mine" (or "yours") version when merging.
But you could adapt the script executed by this merge driver to ask you a question, and then apply your choice to all merges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文