Tuesday, March 4, 2014

Git resolving conflict on remote machine

Git conflict resolution on remote server after two branches merging into master branch
Branches are master, armand and ralph.


File with conflict is i.txt.

Auto-merging i.txt
CONFLICT (content): Merge conflict in i.txt
Automatic merge failed; fix conflicts and then commit the result.
(master)$git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

 both modified:      i.txt

no changes added to commit (use "git add" and/or "git commit -a")

(master)$ cat i.txt 
first
second
<<<<<<< HEAD
line #3
=======
num 3
>>>>>>> armand

(master)$vi i.txt
(master)$git add i.txt 
(master)$git commit -m 'resolved conflict in line 3'

[master 4cb6eac] resolved conflict in line 3

(master)$ git log --pretty=format:"%h - %an , %ar : %s"
4cb6eac - John Bower , 11 seconds ago : resolved conflict in line 3
94e1ff1 - Ralph Schweitzer , 19 minutes ago : modified 3rd line
f6655c8 - Armand Belisle , 22 minutes ago : modif. 3rd line
5ba79fb - Ralph Schweitzer , 31 minutes ago : added 3rd line
8161a1c - Armand Belisle , 35 minutes ago : added 2nd line
5a8e467 - John Bower , 3 hours ago : added first line

(master)$ cat i.txt 
first
second
fixed third line on test server

after resolving conflict

(master)$ git checkout armand 
Switched to branch 'armand'
(armand)$ git merge master
Updating f6655c8..4cb6eac
Fast-forward
 i.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(armand)$ git checkout ralph 
Switched to branch 'ralph'
(ralph)$ git merge master
Updating 94e1ff1..4cb6eac
Fast-forward
 i.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(ralph)$ git checkout master
Switched to branch 'master'

after merging branches armand and ralph into master after conflict resolution

Now branches armand and ralph are in sync with master and can be used to pull on developer machines

No comments:

Post a Comment