In this exercise, you'll practice creating and merging branches. You should complete this exercise by creating your own repository to work with.
To set up the repository, take the following steps:
- Create a new repository on GitHub with a
README.mdfile. - Clone the repository to your machine
In this section, you'll create a new branch, and practice switching between branches.
- Create a new branch called
new-feature - Checkout your new branch (you can do this in the same line as the last step, if you like)
- Edit your
README.mdfile by adding a line (line #2) that says Changes onnew-featurebranch - Then,
addandcommityou changes (note, this commit will only appear on yournew-featurebranch)
In this section, you'll switch branches, make changes, then create a merge conflict when you attempt to merge in changes.
- Switch back to your master branch
- Edit your
README.mdfile by adding a line (line #2) that says Changes onmasterbranch - Then,
addandcommityou changes (note, this commit will only appear on yourmasterbranch) - Merge in changes from your
new-featurebranch (it should result in a merge conflict) - Edit your
README.mdfile to make it appear exactly as you want it (i.e., select changes from your desired branch) - You'll then have to
addyour changes, and make a new commit to reflect your merge - You can then push your changes (all changes) back up to GitHub