Git 合并后保留新更改
Keeping New changes after Git Merge
我试图合并两个分支,但有些文件没有自动合并。
我在非合并文件中有冲突标记,例如:
<<<<<< HEAD
int a=4;
===========
int a=5;
<<<<<<< branch2
如果我总是想在我的文件中保留来自合并分支的更改,即下面的所有内容
=======,有没有命令或脚本的方式来完成而不是手动编辑每个文件?
git merge -X ours other_branch
将保留您的更改。
git merge -X theirs other_branch
会做相反的事情。
如果您在多个文件中存在合并冲突,并且根据您决定保留哪个文件,您可以使用 git 命令
git merge master
Auto-merged default.html
CONFLICT (content): Merge conflict in default.html
Auto-merged index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
您可以决定要保留哪些文件,例如:
git checkout --theirs default.html
git checkout --ours index.html
我试图合并两个分支,但有些文件没有自动合并。 我在非合并文件中有冲突标记,例如:
<<<<<< HEAD
int a=4;
===========
int a=5;
<<<<<<< branch2
如果我总是想在我的文件中保留来自合并分支的更改,即下面的所有内容 =======,有没有命令或脚本的方式来完成而不是手动编辑每个文件?
git merge -X ours other_branch
将保留您的更改。
git merge -X theirs other_branch
会做相反的事情。
如果您在多个文件中存在合并冲突,并且根据您决定保留哪个文件,您可以使用 git 命令
git merge master
Auto-merged default.html
CONFLICT (content): Merge conflict in default.html
Auto-merged index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
您可以决定要保留哪些文件,例如:
git checkout --theirs default.html
git checkout --ours index.html