wyqydsyq
wyqydsyq

Reputation: 2020

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

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

Upvotes: 2

Views: 313

Answers (2)

manojlds
manojlds

Reputation: 301037

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

Upvotes: 6

ralphtheninja
ralphtheninja

Reputation: 132978

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

Upvotes: 2

Related Questions