我们有一个临时环境,可以自动将新分支合并到我们的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/