1

After mergin branches with the master branch I pulled changes to the Git server. After a few days I clones that repository noticing that I cannot compile it (have compile-time errors).

After inspecting, I noticed that Git inserter some text into the one source file. It looked like this

public class MainActivity extends Activity {
<<<<<<< HEAD
    final String TAG = MainActivity.class.getSimpleName();
    private IabHelper mHelper;
    //...rest of the code
    //after 250 lines of code or so again
    //...
        }
    };
=======
    private IabHelper mHelper;
    //this field and all next ones, till the end, are repeated
    //then in the end of a source file, there was
   }
};
>>>>>>> 4
}

So intruders were:

  • <<<<<<< HEAD
  • =======
  • >>>>>>> 4

Why did it happen and how? Was it my fault? I am not so used to Git, I used it in like 3 projects so far.

sandalone
  • 41,141
  • 63
  • 222
  • 338

1 Answers1

2

Those are merge conflict markers.

That means you didn't resolve properly those merge conflicts, added all the files are they were (with said conflicts) and committed.

One way would be to reset you repo before the merge, redo the merge (paying attention to the merge messages) and resolve the conflicts.

See "How do I fix merge conflicts in Git?" for more on the resolution part.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I see. So lines from "Head" to "===" means that those lines are in conflict? And number 4 means that it happened in branch "4"? – sandalone Apr 16 '14 at 07:07
  • What do you mean "reset the repo"? You mean delete it and create new one on the cloud server? – sandalone Apr 16 '14 at 07:08
  • @sandalone no move HEAD back to the commit before your merge, and redo your merge. (http://stackoverflow.com/q/3639342/6309) – VonC Apr 16 '14 at 07:09
  • @sandalone For ====, see the link I mention in my answer: http://stackoverflow.com/a/7589612/6309 – VonC Apr 16 '14 at 07:10
  • Thanks. I skimmed the link but did not know it there as well. – sandalone Apr 16 '14 at 07:11