Skip to main content

MERGING CONFLICT IN GIT

Scenario:
User bob pulled repo from central repository at 9.00AM edited it and pushed back to central repository at 9.30AM. Another user aliced pulled the same repository at 9.10AM edited it and pushed back at 9.40AM.At that time conflict occur.

Solution:
Let us consider bob pulled repo git-test at 9.00AM.




#git init
#git clone git@github.com:arunm8489/git-test.git
#cd git-test
Then he edited file test2 and made certain entries.
Then he committed it
#git commit test2 -m “first commit made bt bob”
Now at 9.30AM he pushed it back to central repository
#git push origin master
Now test2 look as follows:


During the same time Alice is editing the same file and she pushed it back to central repository at 9.40AM.During this time merging conflict will occur.
We can see Alice will not be able to push it back.
#git pull --rebase origin master
This will pull back the central repo with certain limitations.Now we want to find the conflicts.We see on pulling it back the status showing conflict in test2 file.




#git mergetool –tool=vimdiff
Now edit te test2 file as we want to appear in central repo.


 Now the conflict is solved
# git rebase --continue
#git push origin master




Now our test2 file in central repo wil be as above.Thus we solved the conflict issue.