I am following an example from a book which does not show the step to resolve a merge conflict. The tutorial which teaches that did not work for me as mentioned in this post - Simulate multiple users/committer's on local system So, I could not even learn the merge.
Here are the steps copied from the book -
Now open the blank participants.txt
file and paste the following lines in it:
(I added a hyphen before each name)
Finance team
Charles
Lisa
John
Stacy
Alexander
Git code -
git init
git add .
git commit -m 'Initial list for finance team'
Create a new branch called marketing using the following syntax:
git checkout -b marketing
Now open the participants.txt
file and start entering the names for the marketing department below the finance team list, as follows:
(I added a hyphen before each name)
Marketing team
Collins
Linda
Patricia
Morgan
Git code -
git add .
git commit -m 'Unfinished list of marketing team'
git checkout master
Open the file and delete the names Alexander and Stacy, save, close, add the changes, and commit with the commit message Final list from Finance team .
git add .
git commit -m "Final list from Finance team"
git checkout marketing
Open the file and add the fifth name, Amanda, for the marketing team, save, add, and commit.
git add .
git commit -m "Initial list of marketing team"
Say the same names entered for marketing have been confirmed; now we need to merge these two lists, which can be done by the following command.
git merge master
You will get a merge conflict as shown in the following screenshot. Resolve them.
Auto-merging participants.txt
CONFLICT (content): Merge conflict in participants.txt
Automatic merge failed; fix conflicts and then commit the result.
How do I resolve those conflicts ?
The text in the file is as follows -
Finance team
-Charles
-Lisa
-John
<<<<<<< HEAD
-Stacy
-Alexander
Marketing team
- Collins
- Linda
- Patricia
- Morgan
- Amanda
=======
>>>>>>> master