我们有一个临时环境,可以自动将新分支合并到我们的staging分支中,并将我们的网站部署在临时服务器上。
新分支基于我们当前的master分支,然后自动合并staging到git merge -X ours [new branch]. 我们有两个文件想要进行联合合并。这意味着,分支中的所有更改都必须完全复制到文件中。
所以我将这两个文件添加到.gitattributes:
allCampaigns.json merge=union\nf-hero.css merge=union\nRun Code Online (Sandbox Code Playgroud)\n我认为这git merge -X ours适用于除allCampaigns.json和之外的所有文件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。
这个,git merge,保留两者,所以问题正是我想要的,但答案是添加我已经完成的merge=union内容.gitattributes,但它不起作用。
我正在使用 git …
我一直遇到以下问题,我想知道是否有使用现有 git 命令的简单解决方案,或者我是否需要编写自定义合并驱动程序。
这是一个演示我的问题的示例:假设master我的 repo的分支具有以下文件:
$ cat animal.hpp
#include <string>
class Animal
{
public:
virtual std::string say() const = 0;
};
Run Code Online (Sandbox Code Playgroud)
我创建一个名为的新分支mybranch并进行以下更改:
diff --git a/animal.hpp b/animal.hpp
index e27c4bf..3bb691a 100644
--- a/animal.hpp
+++ b/animal.hpp
@@ -5,3 +5,13 @@ class Animal
public:
virtual std::string say() const = 0;
};
+
+class Dog : public Animal
+{
+public:
+ virtual std::string
+ say() const override
+ {
+ return "woof";
+ }
+};
Run Code Online (Sandbox Code Playgroud)
与此同时,其他人添加了以下非常相似的更改master:
diff …Run Code Online (Sandbox Code Playgroud) git git-merge git-rebase merge-conflict-resolution git-merge-conflict