1 00:00:00,600 --> 00:00:04,820 It can sometimes take hours or even days to get a poll request review. 2 00:00:04,820 --> 00:00:08,920 During that time, others have probably been making changes to the repo's master 3 00:00:08,920 --> 00:00:12,450 branch, changes that might conflict with yours. 4 00:00:12,450 --> 00:00:15,580 You don't wanna be surprised by these changes when you merge your topic 5 00:00:15,580 --> 00:00:16,890 branch into master. 6 00:00:16,890 --> 00:00:20,390 So first, it's a good idea to merge master into your branch. 7 00:00:21,470 --> 00:00:25,450 If there are no conflicts, GitHub lets you merge master into your branch at the click 8 00:00:25,450 --> 00:00:29,400 of a button, but it looks like we have a conflict here. 9 00:00:29,400 --> 00:00:32,120 So we'll need to fix it from the command line. 10 00:00:32,120 --> 00:00:34,910 So we'll go to our git repo on our computer. 11 00:00:34,910 --> 00:00:38,130 And first we need to update the master branch with any changes from 12 00:00:38,130 --> 00:00:39,670 the remote repo. 13 00:00:39,670 --> 00:00:44,560 So first, we're going to checkout the master branch, git checkout master. 14 00:00:44,560 --> 00:00:48,040 Then we fetch changes and merge them into master with git pull. 15 00:00:49,170 --> 00:00:50,980 There are no changes in this case, but 16 00:00:50,980 --> 00:00:53,640 if there had been, this would ensure that we incorporate them. 17 00:00:54,820 --> 00:00:58,340 Now, we need to merge the changes for master into our topic branch, so 18 00:00:58,340 --> 00:01:00,760 that we can resolve any conflicts. 19 00:01:00,760 --> 00:01:05,840 We check out the topic branch with git checkout add-letters and 20 00:01:05,840 --> 00:01:11,330 we merge the changes from master end of the topic branch, git merge master. 21 00:01:11,330 --> 00:01:13,100 Looks like there's a conflict to fix. 22 00:01:13,100 --> 00:01:14,520 Let's take care of that real quick. 23 00:01:16,490 --> 00:01:20,590 So it looks like we have some changes both on the add letters branch and 24 00:01:20,590 --> 00:01:22,155 on the master's branch. 25 00:01:22,155 --> 00:01:25,550 We're going to go ahead and keep both sets of changes in this case. 26 00:01:25,550 --> 00:01:27,130 I don't see any problems with them. 27 00:01:29,120 --> 00:01:33,260 So we'll save this and stage it, 28 00:01:33,260 --> 00:01:37,610 git add decoder.rb, which will mark the conflicts as resolved. 29 00:01:38,950 --> 00:01:42,370 And then we'll commit it, with just git commit. 30 00:01:42,370 --> 00:01:46,820 I won't use -m, so that it uses the default message. 31 00:01:46,820 --> 00:01:50,080 I don't wanna change this message at all, so I'm just gonna exit 32 00:01:50,080 --> 00:01:54,410 without making any changes, and that completes the merge commit. 33 00:01:54,410 --> 00:01:58,370 As always, if you're merging code for an app, you should run your unit test suite 34 00:01:58,370 --> 00:02:00,990 and compile the app to make sure nothing is broken. 35 00:02:00,990 --> 00:02:05,150 Ruby test_decoder.rb, looks like all our unit tests are passing. 36 00:02:06,360 --> 00:02:08,520 Now, that your pull request has been reviewed and 37 00:02:08,520 --> 00:02:13,130 you've resolved any conflicts, it should be safe to merge your branch into master. 38 00:02:13,130 --> 00:02:17,170 Again, GitHub offers a shortcut button for this, but we'll show you how to do 39 00:02:17,170 --> 00:02:21,130 it from the Command line, so you understand what the button does. 40 00:02:21,130 --> 00:02:25,840 So start by checking out the master branch, git checkout master. 41 00:02:25,840 --> 00:02:29,700 And we'll check for changes to master one more time, just in case, git pull. 42 00:02:31,270 --> 00:02:35,260 If it shows further changes, you'll need to repeat the process of merging master 43 00:02:35,260 --> 00:02:39,330 into your topic branch, but it hasn't been very long, so it probably won't. 44 00:02:39,330 --> 00:02:45,110 And now, you merge your topic branch into your master branch, git merge add-letters. 45 00:02:45,110 --> 00:02:48,510 Because we just recently merged master into our topic branch, 46 00:02:48,510 --> 00:02:51,620 it's able to merge by fast-forwarding. 47 00:02:51,620 --> 00:02:54,603 Now, you should be able to push your master branch, git push. 48 00:02:59,288 --> 00:03:03,004 If you refresh the pull request page, you'll see that the changes have been 49 00:03:03,004 --> 00:03:06,850 merged into master, the same as if you'd pushed GitHub's shortcut button. 50 00:03:08,120 --> 00:03:10,350 Now, you can safely clean everything up. 51 00:03:10,350 --> 00:03:12,610 You can click the button to Close pull request. 52 00:03:13,700 --> 00:03:17,340 You can also click the button to delete the branch of the GitHub repository, 53 00:03:17,340 --> 00:03:18,970 since it won't be needed anymore. 54 00:03:21,260 --> 00:03:25,983 And since the changes from your local branch have all been merged in a master, 55 00:03:25,983 --> 00:03:29,486 you can delete that as well, git branch -d add letters. 56 00:03:32,372 --> 00:03:33,980 You're still not quite done yet. 57 00:03:33,980 --> 00:03:36,290 Now it's time to release your software. 58 00:03:36,290 --> 00:03:40,440 For most projects, the master branch represents what's deployed to production. 59 00:03:40,440 --> 00:03:44,240 If you're working on a web app, that means the latest version on master is what 60 00:03:44,240 --> 00:03:47,500 should be set up on the web server for people to use. 61 00:03:47,500 --> 00:03:50,850 If you're making an app that people install to their computers or phones, 62 00:03:50,850 --> 00:03:53,230 the latest version of master should be compiled, and 63 00:03:53,230 --> 00:03:56,110 made available on a server for people to download. 64 00:03:56,110 --> 00:03:59,310 Most teams choose to write scripts that will automatically pull code from 65 00:03:59,310 --> 00:04:01,570 the master branch and deploy it for you. 66 00:04:01,570 --> 00:04:04,040 If you're working on a project that has such a script, 67 00:04:04,040 --> 00:04:06,260 now would be the time to run it. 68 00:04:06,260 --> 00:04:09,980 But that's another project to complete using other tools. 69 00:04:09,980 --> 00:04:11,830 For now, give yourself a pat on the back, 70 00:04:11,830 --> 00:04:15,810 because you've mastered an important concept Git branches. 71 00:04:15,810 --> 00:04:19,890 You now know everything you need to be a productive collaborator on Git repos.