When I try to pull I have the following message:
Automatic merge failed; fix conflicts and then commit the result.
So, I try to fix conflict (as git suggest) for that I follow these instructions.
Among the first things that I need to do is to open the "problematic" file in a text editor and find lines like that
If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a
The problem is that I do not see things like that in my file. In particular I searched for HEAD and it is not there.
There are several ways to solve git conflicts, I will explain here using GUI and text editor way.
Open any one of your favourite editor, example, Notepad, gedit, vim, nano or even Eclipse.
Whenever there is conflict in a file git add conflict marker that looks like this <<<<<<<<
.
When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD
========
, it divides your changes from the other branch as >>>>>>>>YOUR_BRANCH_NAME
You can decide if you want keep your branch changes or not. If you want to keep the changes what you did, delete the conflict marker they are,<<<<<<<, =======, >>>>>>>
and then do a merge.
Commands to commit the changes.
git add . or git add "your_file"
git commit -m "Merge conflicts resolved"
What if you have so many merge conflicts in files? In that case you can use GUI, well its just personal choice whether to opt for GUI or not. In GUI, you can see side by side diff. It is easy for the beginners to see the changes.
You need to configure your git to use the mergetool you want to use. Example: meld, kdiff3 or vimdiff. Again it's upto the user what they prefer. I use meld. Here you need to install these tool, after installation you have to configure it.
git config merge.tool meld
you can solve merge conflicts
git mergetool -t meld
Then you can follow the step 2 to 4 from solving using text editor, to solve the merge conflicts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With