Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merge - Conflict markers missing

Using Windows 7, git 1.9.5.msysgit.1

The tutorials I've read about merge conflicts in Git suggest that failed merges will cause conflict markers to be placed at problematic points in the file. I can't seem to get this to happen. Here is a sample workflow for a fresh repository:

git init
notepad file1.txt    #make some edits
git add .
git commit -m "msg"

git branch mybranch
git checkout mybranch
notepad file1.txt #make some edits on line 3
git add .
git commit -m "msg"

git checkout master
notepad file1.txt #make a conflicting edit on line 3
git add .
git commit -m "msg"
git merge mybranch
#error: 'merge' is not possible because you have unmerged files

notepad file1.txt

After opening file1.txt the last time, I was expecting to see the hallmark >>>>>>>> and ========== conflict markers around line 3... but there's nothing there, just the text of the file as it appears in the master branch. My global .gitconfig file:

[user]
    name = Andrew Barger
[core]
[core]
    attributesfile = ~/.gitattribtues
    editor = 'C:\\Program Files (x86)\\Vim\\VIM74\\gvim.exe'
[merge]
    conflictStyle = diff3
[rerere]
    enabled = true

What's preventing me from reviewing my conflicts?

EDIT: This answer, by the way, did not assist me. I do not appear to have any .gitattributes files. Here, though, is the output of gitconfig --list, if that helps:

PS C:\GitRepos\git_sandbox> git config --list
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=Andrew Barger
core.attributesfile=~/.gitattribtues
core.editor='C:\Program Files (x86)\Vim\VIM74\gvim.exe'
merge.conflictstyle=diff3
rerere.enabled=true
alias.edit-unmerged=!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; vim `f`
alias.add-unmerged=!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; git add `f`
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
like image 674
abarger Avatar asked Sep 17 '15 23:09

abarger


2 Answers

In my case, the conflict markers weren't appearing because the file in conflict was encoded using UTF-16, which apparently doesn't play well with Git. I realized this due to azurefrog's suggestion to view the files using git gui, which clearly indicated that Git couldn't compare the files because it considered them to be binaries.

Moral of the story: use UTF-8 encoding.

like image 192
abarger Avatar answered Dec 03 '22 08:12

abarger


I would say, that it can be caused by the enabled rerere option in your .gitconfig. It means "reuse recorded resolution" and simply says Git to resolve conflict the same way as it was resolved previously.

Therefore there are no conflict markers, because Git actually solved that conflict already. Try to repeat your workflow with this option disabled.

like image 31
David Ferenczy Rogožan Avatar answered Dec 03 '22 08:12

David Ferenczy Rogožan