Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We've merged the code that fixes the `nil` error into our `master` branch. But right now it's not available on any other topic branch. We can fix that by merging from the `master` branch into our topic branches.
We've merged the code that fixes the nil
error into our master
branch. But right now it's not available on any other topic branch. We can fix that by merging from the master
branch into our topic branches.
- Let's try checking out our
testing
branch:git checkout testing
- If we try running our unit tests, we'll see the same problem that we had with our main program:
ruby test_decoder.rb
- It shows errors whenever it fails to convert a number to a letter.
- We fixed this issue, but only on the master branch.
- We need to merge commits from the
master
branch into thetesting
branch so that the bug fix is present here as well:git merge master
- This time things go a little differently. Git needs to make a new commit for this merge.
- So it brings up an editor so we can edit the commit message.
- In the previous video, we based the
fix-nils
branch off of themaster
branch. - And then we didn't make any commits to the
master
branch before mergingfix-nils
into it. - So Git was able to do a "fast-forward" merge previously.
- But we have made commits to the
testing
branch since we created it. So Git can't do a fast-forward this time. - Instead, it needs to make a merge commit. This is a special type of commit that merges code from two branches together.
- That's why it displays an editor for the commit message.
- In most cases you should just keep the default message and just quit out of the editor.
- When the editor closes, Git completes the commit.
- If you run
git log
now, you'll see our "Fix error with missing letters" commit is now here on thetesting
branch.- You'll also see the merge commit at the top.
- This includes a special
Merge
line that shows partial SHA checksums for the commit's two parents. - Most commits have only one parent commit, but merge commits have two parents - the latest commits from the two branches being merged.
- The two parents in this case are the "Add test with more letters" commit from the
testing
branch, and the "Fix error with missing letters" commit from themaster
branch. - Both parent commits appear here in the history before the merge commit.
commit a305f48c593944b56df3b651d1faa52e7d87c0a6 (HEAD -> testing)
Merge: 01c21ce 0302dd0
Author: Jay McGavren <me@example.com>
Date: Sat Oct 6 13:38:09 2018 -0700
Merge branch 'master' into testing
commit 0302dd022d681ddd3e521cfc12b97fb9521e6670 (master)
Author: Jay McGavren <me@example.com>
Date: Sat Oct 6 13:20:50 2018 -0700
Fix error with missing letters
commit 01c21ced52c664acf1362fa003ffc47bcde838ce
Author: Jay McGavren <me@example.com>
Date: Wed Sep 26 20:00:18 2018 -0700
Add test with more letters
...
- We've brought our latest commits from the
master
branch into thetesting
branch, but that doesn't bring the tests into themaster
branch. To do that, we'll need to do a merge in the other direction, fromtesting
tomaster
. - Since we just merged the
master
branch into ourtesting
branch, we should be able to cleanly merge thetesting
branch into themaster
branch as well.- Let's check out the
master
branch:git checkout master
- And let's merge the
testing
branch intomaster
:git merge testing
- Notice that it does a fast-forward merge. This is because the latest commit from the
master
branch is already present on thetesting
branch, thanks to the earlier merge. So Git is able to simply move themaster
branch pointer to the latest commit on thetesting
branch. - Since we already did a merge from
master
totesting
, we don't have to worry about any ugly merge conflicts when merging fromtesting
tomaster
.
- Let's check out the
- We no longer need the
testing
branch, so let's not forget to delete it:git branch -d testing
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up