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.md
file. - 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.md
file by adding a line (line #2
) that says Changes onnew-feature
branch - Then,
add
andcommit
you changes (note, this commit will only appear on yournew-feature
branch)
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.md
file by adding a line (line #2
) that says Changes onmaster
branch - Then,
add
andcommit
you changes (note, this commit will only appear on yourmaster
branch) - Merge in changes from your
new-feature
branch (it should result in a merge conflict) - Edit your
README.md
file to make it appear exactly as you want it (i.e., select changes from your desired branch) - You'll then have to
add
your changes, and make a new commit to reflect your merge - You can then push your changes (all changes) back up to GitHub