You know how to create branches on Git and how to complete the related PR (do you?)However, you ran into something you weren't ready for - Merge conflicts.
Let's set up a simple situation to grasp the concept more easily: in the master branch you have this index.html
.
index.html(master branch)
<div>
<p>I like:</p>
<ul>
<li>dogs</li>
<li>sea</li>
<li>summer</li>
</ul>
</div>
In another branch named overriding-branch
the same index.html
present:
index.html(overriding-branch branch)
<div>
<p>I like:</p>
<ul>
<li>cat</li>
<li>mountain</li>
<li>winter</li>
</ul>
</div>
On both branches, both files are committed to their origin - if you make a change to the file without committing, the moment you change branch and this last already has something in that line you will get this error
So, being in the master branch, enter the command git diff overriding-branch
.
And immediately you realize that the two files are not overlapping. In fact, by running git merge master
.
And it is no coincidence that the file in your IDE has changed like so:
Then you can resolve the conflict using the links above:
- Accept Current Change - keep the version of the branch you were on at the time of merging
- Accept Incoming Change - use the version of the branch with which the merge is required
- Accept Both Changes
Otherwise, you can manually intervene directly in the IDE:
Of course, you now need to commit and push the updated file:
You got carried away and made a commit you shouldn't have done? Don't despair, going back is ... within console reach. That's how it is done [VERY_VERY_SOON].
Otherwise, take a look at the concept of the fork [VERY_VERY_SOON].
๐ค twitter: https://twitter.com/did0f
Top comments (0)