Git 冲突标记

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7901864/
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 12:10:00  来源:igfitidea点击:

Git conflict markers

gitgit-merge-conflict

提问by Mellon

After I pulled from remote branch, I got conflict, when I open the file it looks something like below:

从远程分支拉出后,我遇到了冲突,当我打开文件时,它看起来像下面这样:

<<<<<<< HEAD:file.txt
Hello world
=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

I need some explanations of the markers, which portion of code is pulled from remote and which is from local?

我需要对标记进行一些解释,哪部分代码是从远程提取的,哪些是从本地提取的?

What does the code 77976da35a11db4580b80ae27e8d65caf5208086stand for?

代码77976da35a11db4580b80ae27e8d65caf5208086代表什么?

回答by Mark Longair

The line (or lines) between the lines beginning <<<<<<<and ======here:

开头<<<<<<<======此处之间的行(或多行):

<<<<<<< HEAD:file.txt
Hello world
=======

... is what you already had locally - you can tell because HEADpoints to your current branch or commit. The line (or lines) between the lines beginning =======and >>>>>>>:

... 是您在本地已经拥有的 - 您可以判断,因为HEAD指向您当前的分支或提交。以=======和开头的行之间的一行(或多行)>>>>>>>

=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

... is what was introduced by the other (pulled) commit, in this case 77976da35a11. That is the object name (or "hash", "SHA1sum", etc.) of the commit that was merged into HEAD. All objects in git, whether they're commits (version), blobs (files), trees (directories) or tags have such an object name, which identifies them uniquely based on their content.

... 是由另一个(拉取的)提交引入的,在这种情况下是77976da35a11. 那是合并到HEAD. git 中的所有对象,无论是提交(版本)、blob(文件)、树(目录)还是标签,都有这样的对象名称,它根据内容唯一地标识它们。