git CONFLICT(内容):合并冲突

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11091969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:57:23  来源:igfitidea点击:

CONFLICT (content): Merge conflict in

gitconflictgit-pull

提问by Tony

I have a server with a remote and whenever I git pullI get those stupid ====== and HEAD >>>> things in my files causing my server to not work properly. How can I prevent this every time I want to update my server to be the same as my origin/master?

我有一个带遥控器的服务器,每当我git pull在我的文件中遇到那些愚蠢的 ====== 和 HEAD >>>> 东西时,都会导致我的服务器无法正常工作。每次我想将我的服务器更新为与我的源/主服务器相同时,如何防止这种情况发生?

This is what I did:

这就是我所做的:

git pull production master

Then I got this:

然后我得到了这个:

CONFLICT (content): Merge conflict in 

When I do a git statusI get this:

当我做一个git status我得到这个:

Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)

    both modified:      photocomp/settings.py
    both modified:      photocomp/wsgi.py

采纳答案by Peter van der Does

It seems like you modify files locally.

看起来你在本地修改文件。

If you want to keep a pristine branch of your remote master, I suggest you pull the remote master in a separate branch, like you seem to do but do any modifications in a separate branch.

如果您想保留远程 master 的原始分支,我建议您将远程 master 拉到一个单独的分支中,就像您似乎所做的那样,但在单独的分支中进行任何修改。

回答by Jiemurat

But it is not stupid thing :) Git marks conflicts (see Merge conflicts in Git) by this way. You must be trying to overwrite changes which haven't been pushed.

但这并不愚蠢:) Git通过这种方式标记冲突(请参阅Git 中的合并冲突)。您必须尝试覆盖尚未推送的更改。

<<<<<<<: Indicates the start of the lines that had a merge conflict.

<<<<<<<: 表示有合并冲突的行的开始。

=======: Indicates the break point used for comparison. Breaks up changes that user has committed (above) to changes coming from merge (below) to visually see the differences.

=======:表示用于比较的断点。将用户已提交(上)的更改分解为来自合并(下)的更改,以直观地查看差异。

>>>>>>>: Indicates the end of the lines that had a merge conflict.

>>>>>>>: 表示有合并冲突的行的结尾。

Resolve a conflict by editing the file to manually merge the parts of the file that git had trouble merging. This may mean discarding either your changes or someone else's or doing a mix of the two. You will also need to delete the <<<<<<<, =======, and >>>>>>>in the file.

通过编辑文件以手动合并 git 无法合并的文件部分来解决冲突。这可能意味着放弃您或其他人的更改,或者将两者混合使用。你也将需要删除<<<<<<<=======以及>>>>>>>在文件中。