The merge was successful because master
had not changed since we made a commit on fencing
. Git knew to simply update master
with changes on fencing
.
What would happen if you made a commit on master
before you merged the two branches? Furthermore, what if the commit you made on master
altered the same exact text you worked on in fencing
? When you switch back to master
and ask Git to merge the two branches, Git doesn’t know which changes you want to keep. This is called a merge conflict.
Instructions
You are on the master
branch. In the code editor, where you have written:
-Engage in swordfights with pirates
Add the word “professional”, so the text reads:
-Engage in swordfights with professional pirates
Click Run.
Add resume.txt to the staging area.
Commit the changes to the repository with a commit message.
Imagine a few weeks have passed, and you’d like to develop your fencing resumé some more.
Switch back to the fencing
branch.
From fencing
, change the line so it reads:
-Engage in swordfights with professional pirates such as Smee.
Click Run.
Once again, add resume.txt to the staging area.
Commit the changes to the repository with a commit message.