5.4 Handling Conflicts
What happens when you edit the same file in different ways in two different branches and then try to merge them? Git tries to merge them together, but sometimes it can’t.
It is called a conflict when Git can’t automatically merge the commits together. Conflicts occur most commonly when the same area in a file is changed in different ways in each branch. For example, you might use a different variable name in each branch. Git can’t tell which one you want to use, so it stops with a conflict and lets you fix it.
Let’s demonstrate how a conflict works. First, let’s create a new branch
called about to add our work in:
|
prompt> git checkout -b about master |
|
|
Switched to branch "about" |
Next, add ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access