如何使用git合并驱动,union?

2024-03-19

我们有一个临时环境,可以自动将新分支合并到我们的staging在临时服务器上分支并部署我们的网站。

一个新的分支是基于我们当前的master分支,然后自动合并到staging with git merge -X ours [new branch]。我们有两个文件想要进行联合合并。这意味着,分支中的所有更改都必须完全复制到文件中。

所以我将这两个文件添加到.gitattributes:

allCampaigns.json merge=union
f-hero.css merge=union

我以为git merge -X ours将适用于除allCampaigns.json and f-hero.css但事实并非如此。如果是allCampaigns.json,新的 JSON 会覆盖另一个分支 JSON,在这种情况下git merge -X theirs并在以下情况下完全省略git merge -X ours.

只是为了测试,我不想对所有文件进行联合合并,我尝试过git merge -X union但这给了我一个致命的错误:fatal: Unknown option for merge-recursive: -Xunion.

This, git merge,保留两者 https://stackoverflow.com/questions/13263902/git-merge-keep-both,所以问题正是我想要的,但答案是添加merge=union in .gitattributes我已经做到了,但它不起作用。

我使用的是 git 版本 2.30.2,我们的服务器(进行合并)使用的是 git 版本 2.25.1 - 两者都是 Linux 机器。

几乎就像联合合并不存在。

我应该如何使用联合合并驱动程序 https://git-scm.com/docs/gitattributes#_built_in_merge_drivers?

文件概览

以下是网站文件的简化概述。它显示根级别的文件和文件夹,以及f-英雄.css.

.
├── .editorconfig
├── .git
├── .gitattributes
├── .gitignore
├── AWS_S3/
├── Makefile
├── README.md
├── allCampaigns.json
├── allCampaigns.schema.json
├── app.js
├── bin/
├── config/
├── node_modules/
├── package-lock.json
├── package.json
├── post-mortem.md
├── public/
├── server/
├── spec/
├── styles/
│   ├── base.css
│   └── blocks/
│       ├── f-hero.css
│       └── f-white-card.css
├── tools/
└── views/

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用git合并驱动,union? 的相关文章

随机推荐