I have 2 branches, master
and newfeature
. When I want to merge newfeature
into master
, I used:
git checkout master git merge newfeature
I get the error:
Auto-merging .gitignore CONFLICT (content): Merge conflict in .gitignore Automatic merge failed; fix conflicts and then commit the result.
I opened up .gitignore
and it looks like a mess now with the last part of the file looking like
<<<<<<< HEAD public/img/ignore ======= public/img/profiles public/blog public/recommendation >>>>>>> newfeature
What happened, and how should this be fixed so that I can merge the branch into master
?
The simplest way, if you have unmerged paths, use git merge --abort to abort the merge. This way your code will look the same as it was before trying to merge with some other branch...
Note the list of conflicted files with: git status (under Unmerged paths section). Solve the conflicts separately for each file by one of the following approaches: Use GUI to solve the conflicts: git mergetool (the easiest way). To accept remote/other version, use: git checkout --theirs path/file .
When you pull or merge branches, Git will select the recursive strategy as default. The recursive strategy only can detect and do merges which involve renames, but cannot use detected copies. The ours option forces conflicted parts to be automatically resolved by favoring 'our' version.
You edited the .gitignore in both branches. Now, git is unsure of which lines in each copy are the correct ones so it is asking you to resolve them.
The lines:
<<<<<<< HEAD public/img/ignore =======
Are what appears in the copy of the file in master.
And
======= public/img/profiles public/blog public/recommendation >>>>>>> newfeature
in the branch newfeature
You should just have to edit the file as you would like it to appear finally. Then...
git add .gitignore git commit
Simply edit .gitignore
file to resolve conflict:
Before
<<<<<<< HEAD public/img/ignore ======= public/img/profiles public/blog public/recommendation >>>>>>> newfeature
After
public/img/ignore public/img/profiles public/blog public/recommendation
Then:
git add .gitignore
git commit
Autogenerated commit message should apear, accept it (save & close) and it's done.
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