Reputation: 43
Today I pushed some code, and it appeared that everything went smoothly (no error messages), but when I opened the code in my IDE it was peppered with new stuff that looked like:
<<<<<<< HEAD
=======
>>>>>>> 61fab429c996f1ca998cb5acb4csbbebd282b11a
private void function(string[] args)
{
<<<<<<< HEAD
=======
>>>>>>> 61fab429c996f1ca998cb5acb4csbbebd282b11a
What gives? What happened? And what should I do to prevent it in the future?
Upvotes: 1
Views: 263
Reputation: 114787
<<<<<<< HEAD
=======
>>>>>>> 61fab429c996f1ca998cb5acb4csbbebd282b11a
When git tries to merge files but detects, that a certain line in the document has been changed on both branches, that have to be merged, then in adds those kind of lines to the file. Merging happens automatically when you pull from a remote repository (a pull is fetch followed by a merge).
The merge is not finished right now. The normal task would be to edit that file and decide, how the merged file should look like, than save that file, do a git add <file>
and commit the change.
Your file looks somewhat strange. The different lines appear to be empty. This could happen when the file has been autoformatted on both branches but with tabs on the one side and spaces on the other... Just a guess. The part between "Head" and the "===" is the code from your actual branch, the other half the change from the remote repository.
Upvotes: 3
Reputation: 1984
These are called merge conflicts. A good way to go through these conflicts so as not to have all this 'garbage' in them is to use a merge tool.
Upvotes: 4
Reputation: 27792
This happens when you try to merge your changes, but there are conflicts that can't be autoresolved. To fix this, you have to manually resolve these conflicts. You can use TortoiseMerge to resolve the conflicts.
Upvotes: 3