PHP ZCE mock test, interview preparation, daily lessons under chalk talk

Wednesday, December 5, 2012

git resolve merge or rebase conflicts

When you do rebase or merge on your local git repository, there are chances that snippet of code changed by you is also changes by one of your colleague.



If such case occurs, git has no clue on which one to choose and which one to reject. You need to dig into the files, see the changes and decide on which one to keep.Git helps us in doing so by means of two files.

1. It creates file_with_conflict.php.orig --> it contain your local, original file before merge happened.


2. file_with_conflict.php --> it notifies you of changes done by your colleague and how they are contradicting your changes.


3. You will find below symbols in file_with_conflict.php

<<<<<<< HEAD
changes in your local repository
========
changes done by your colleague
.>>>>>> commit name of your colleague


4. Meanings of these notations are as

<<<<<<<: Indicates the start of the lines that had a merge conflict. The first set of lines are the lines from the file that you were trying to merge the changes into.

=======: Indicates the break point used for comparison. Breaks up changes that user has committed (above) to changes coming from merge (below) to visually see the differences.

>>>>>>>: Indicates the end of the lines that had a merge conflict.



If you find it helpful or if you have any queries, please leave your valuable comments.

No comments:

Post a Comment