This was the initial snapshot of my git repository
On branch master
, file m1
contains
L1
On branch dev
, file m1
contains
L1
L2
If I try to merge dev
from master
, it results in a conflict.
$ git checkout master
Switched to branch 'master'
$ git merge dev
Auto-merging m1
CONFLICT (content): Merge conflict in m1
Automatic merge failed; fix conflicts and then commit the result.
$ git diff
diff --cc m1
index 078f94b,9f46047..0000000
--- a/m1
+++ b/m1
@@@ -1,1 -1,2 +1,5 @@@
L1
++<<<<<<< HEAD
++=======
+ L2
++>>>>>>> dev
Though I didn't modify line 2 of m1
in master
, how did it result in a conflict?
To verify actual contents of the file and to be sure if this is caused by white-spaces:
On branch master
git branch
dev
* master
$ xxd m1
0000000: 4c31 0a L1.
On branch dev
$ git checkout dev
Switched to branch 'dev'
$ xxd m1
0000000: 4c31 0a4c 320a L1.L2.
Here's the script I used to create this repo.
#!/bin/bash
mkdir git_demo
cd git_demo
git init
touch m1
git add .
git commit -m "Added file: m1"
# sleep is needed, otherwise a different repo is being created, probably because of *some* filesystem issue!
sleep 1
git branch dev
echo L1 >> m1
git add .
git commit -m "Added line L1 to m1"
# sleep is needed, otherwise a different repo is being created, probably because of *some* filesystem issue!
sleep 1
git checkout dev
echo L1 >> m1
git add .
git commit -m "Added line L1 to m1"
# sleep is needed, otherwise a different repo is being created, probably because of *some* filesystem issue!
sleep 1
echo L2 >> m1
git add .
git commit -m "Added line L2 to m1"
# sleep is needed, otherwise a different repo is being created, probably because of *some* filesystem issue!
gitg --all
git checkout master
git merge dev