Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git how to remove conflict markers from files? [duplicate]

Tags:

git

>>>>>>> master
      .row
        - @power.next_invoice.tap do |invoice|

        %p
          = link_to t(".postings"), postings_path
<<<<<<< HEAD
    .span9{style: 'margin-top: 50px;'}
=======
    .span9
>>>>>>> master

Somehow these master and head comments/code have been added all over my code in all files. How do I remove them?

like image 974
Rails beginner Avatar asked Sep 05 '25 03:09

Rails beginner


2 Answers

This happens when you have a merge conflict between two commits in your git repository.

You can either use a mergetool, or you can manually delete these instances (if your editor allows for search and replace, search for instances of <<<<<<< HEAD and >>>>>>> master to delete them)

In your example, I can see there you have a duplicate code here -

<<<<<<< HEAD
    .span9{style: 'margin-top: 50px;'}
=======
    .span9
>>>>>>> master

You have to decide if your wan .span9{style: 'margin-top: 50px;'} or if you want .span9 (I am assuming you have more css definitions below that). And delete the other option accordingly. ====== should also be removed.

Once you have made your decision, you should run

git status

which will show you that you have updated this particular css file and chances are you will also have a .orig copy of this file created by git. Delete the .orig file, and git add/commit to complete your merge conflict resolution.

like image 75
Calvin Cheng Avatar answered Sep 08 '25 00:09

Calvin Cheng


Those indicate areas where Git wasn't able to automatically merge your code. For example, this sections shows differences between your HEAD (top) and master (bottom) for the .span9 css style.

<<<<<<< HEAD
    .span9{style: 'margin-top: 50px;'}
=======
    .span9
>>>>>>> master

You will need to edit your files to manually merge them by choosing either your code, the merged code, or a combination of the two, and then commit your changes.

Read more about Git Branching and Merging.

like image 27
doublesharp Avatar answered Sep 07 '25 23:09

doublesharp