开发者

Why does git modify my files? How do i undo it?

开发者 https://www.devze.com 2023-03-02 16:06 出处:网络
Hey, so I\'m a complete git newbie here, the most advanced thing I\'ve done is just basic pulls/pushes .etc

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:

f开发者_JAVA技巧oobar

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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消