Search code examples
gitgithubgithub-for-mac

Pushing my code from Github Desktop places some merge conflict delimiters in my program


Learning how to use Git, and I've being using Github Desktop (Mac OS) as my GUI. Pushing my local fork to my repo has been having some odd side effects to my local code. It's been placing lines such as

<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes

around my recent changes, which appear in my editor (Atom)

Is this a silly mistake on my part, or a bug? Thanks!


Solution

  • A pull in git means a fetch of the remote commits and a merge into the local branch. Sometimes the merge can not be done directly because of conflicts between the changes on the remote and local versions. In this case git will create a temporary version of the conflicted file, with the areas that can not be merged marked as you have shown. The part between <<< and === is the version from the remote. The part between === and >>> is the local version.

    When such a conflict happens, git will usually give you an error message with a list of affected files, and an opportunity to resolve the conflict(s) . If you ignore this message and add a file into the merge commit as-is, it will retain the artifacts you are seeing. The correct procedure in response to a merge conflict would be to open each file that needs massaging individually and fix the areas git can not merge automatically before proceeding.