为什么 git 会修改我的文件?我该如何撤消它?

发布于 2024-11-04 18:34:10 字数 442 浏览 2 评论 0原文

嘿,所以我是一个完整的 git 新手,我所做的最高级的事情只是基本的拉/推等。

出于我不明白的原因,我的一个提交编辑了一堆文件,包括嵌入到文件中自上次提交以来我所做的编辑,例如:

foo.txt:

bar

那么如果我将其编辑为:

foobar

提交时的文件更改为类似:

<<<<<<< HEAD
bar
=======
foobar
>>>>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

X 是提交代码或其他内容。

对我的源文件进行的这些编辑是什么?如何删除它们?

感谢您对此的任何帮助

Hey, so I'm a complete git newbie here, the most advanced thing I've done is just basic pulls/pushes .etc

For reasons I don't understand one of my commits edited a heap of files, including embedded into the file the edits I made since the last commit, for example:

foo.txt:

bar

then if i edited it to:

foobar

the file upon committing got changed to something like:

<<<<<<< HEAD
bar
=======
foobar
>>>>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

with the X's being the commit code or whatever.

What are these edits to my source files, and how do I get rid of them?

Thanks for any help with this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

jJeQQOZ5 2024-11-11 18:34:10

这些代表合并冲突。您的提交导致文件发生冲突。

<<<<<<< HEAD
bar

代表 HEAD 中已经存在的内容,

foobar
>>>>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

显示您正在尝试合并的内容。

请参阅此处的“解决合并”部分: http://git -scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

Those represent merge conflicts. Your commit is causing conflicts to the file.

<<<<<<< HEAD
bar

represents what is already in the HEAD

foobar
>>>>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

shows what you are trying to merge.

Look here at Resolving a Merge section: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

晚雾 2024-11-11 18:34:10

除了 manojlds 之外:

您还可以使用以下配置指定在合并冲突中使用共同祖先的版本(用管道 ||||| 分隔):

git config merge.conflictstyle diff3

这将使冲突看起来像:

<<<<<<< HEAD
roses are #ff0000
violets are #0000ff
|||||||
roses are red
violets are blue
=======
Roses are red,
Violets are blue,
>>>>>>> master

查看更多关于 < a href="http://blog.wuwon.id.au/2010/09/painless-merge-conflict-resolution-in.html" rel="nofollow">凯文的博客

In addition to manojlds:

You can specify to have the version of the common ancestor in your merge conflict (separated by pipes |||||), by using the following configuration:

git config merge.conflictstyle diff3

This would make the conflict look like:

<<<<<<< HEAD
roses are #ff0000
violets are #0000ff
|||||||
roses are red
violets are blue
=======
Roses are red,
Violets are blue,
>>>>>>> master

Check out more on Kevin's Blog

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文