1 00:00:00,490 --> 00:00:04,190 Let's actually contribute some code back to the open source project. 2 00:00:04,190 --> 00:00:07,925 We already created a fork of the hello-treehouse Project earlier. 3 00:00:07,925 --> 00:00:12,022 Let's clone your version of the repository locally, make the fix and 4 00:00:12,022 --> 00:00:13,840 create a pull request. 5 00:00:13,840 --> 00:00:16,770 For this video we'll use your local environment and 6 00:00:16,770 --> 00:00:18,050 I'll walk you through each step. 7 00:00:19,340 --> 00:00:23,471 First, let's make sure we have a copy of the fork repository locally. 8 00:00:23,471 --> 00:00:26,644 To find the fork repository from the GitHub dashboard, 9 00:00:26,644 --> 00:00:31,516 click on the context switch or on the top left, and choose our organization's name. 10 00:00:31,516 --> 00:00:34,560 Now you should see a list of repositories on the right. 11 00:00:34,560 --> 00:00:37,510 Let's click the hello-treehouse repository. 12 00:00:37,510 --> 00:00:40,980 We'll copy the URL from GitHub and then go to our terminal. 13 00:00:42,030 --> 00:00:45,700 We'll run git clone and paste the URL. 14 00:00:47,790 --> 00:00:53,505 Then we'll move into the hello-treehouse folder and I'll clear our console. 15 00:00:53,505 --> 00:00:57,300 To make a change, the first thing we'll want to do is create a branch. 16 00:00:57,300 --> 00:01:01,860 By creating a branch, we're creating an easy way for us to create a pull request. 17 00:01:01,860 --> 00:01:07,419 If you remember in the git basics course you can create a branch using git checkout 18 00:01:07,419 --> 00:01:12,540 -b and let's call this branch fix treehouse-bug. 19 00:01:12,540 --> 00:01:16,940 Great now we have a new branch and git has automatically moved us on to that branch. 20 00:01:16,940 --> 00:01:19,107 Now let's make the simple fix. 21 00:01:19,107 --> 00:01:26,010 If I open up the start.rb file using vim, we can see, there's the error. 22 00:01:26,010 --> 00:01:29,010 We're raising a runtime error that says, 23 00:01:29,010 --> 00:01:32,689 don't start it will explode, let's remove that. 24 00:01:32,689 --> 00:01:37,947 I'm gonna save this file, and then now let's add this change to git, 25 00:01:39,478 --> 00:01:41,909 And we'll create a new commit. 26 00:01:41,909 --> 00:01:50,169 Add a simple commit message, And then Save the commit. 27 00:01:50,169 --> 00:01:53,373 Last but not least we need to push this change to GitHub. 28 00:01:53,373 --> 00:02:01,989 We'll do that by running git push origin fix-treehouse-bug, and add our user name. 29 00:02:06,441 --> 00:02:11,513 All right, we've created the branch, made the fix, and pushed it up to GitHub. 30 00:02:11,513 --> 00:02:14,026 Now, let's go create our pull request. 31 00:02:14,026 --> 00:02:17,424 Let's go back to the fork of the hello-treehouse project on 32 00:02:17,424 --> 00:02:18,431 the GitHub site. 33 00:02:18,431 --> 00:02:22,939 You'll notice now that there's this new section called recently pushed 34 00:02:22,939 --> 00:02:26,646 branches are fixed treehouse bug branches here and now we can 35 00:02:26,646 --> 00:02:31,603 easily create a pull request by clicking on the Compare and pull request button. 36 00:02:33,240 --> 00:02:37,053 This looks a lot like the pull request window we saw earlier in the course, but 37 00:02:37,053 --> 00:02:38,531 there is one big difference. 38 00:02:38,531 --> 00:02:42,680 This pull request is comparing our fork to the original project. 39 00:02:42,680 --> 00:02:47,036 This means that we're trying to move this code from our fork into the original 40 00:02:47,036 --> 00:02:48,521 projects master branch. 41 00:02:48,521 --> 00:02:52,350 This is how most open source projects get changes from contributors. 42 00:02:52,350 --> 00:02:57,020 The contributor forks creates a branch and then opens a pull request between their 43 00:02:57,020 --> 00:03:00,090 forks branch and the original projects master branch. 44 00:03:00,090 --> 00:03:02,864 Now let's fill in this pull request form, 45 00:03:02,864 --> 00:03:07,654 similar to how we submitted the open source issue let's add a clear name. 46 00:03:07,654 --> 00:03:11,822 GitHub already provides a sub title from the commit that we created, and 47 00:03:11,822 --> 00:03:14,498 then let's describe the change that we made. 48 00:03:24,279 --> 00:03:28,472 Great, for a more complex pull request or a real open source project, 49 00:03:28,472 --> 00:03:32,038 there are a few other guidelines that are worth following. 50 00:03:32,038 --> 00:03:35,952 These extra guidelines are often spelled out in the projects read me or 51 00:03:35,952 --> 00:03:38,814 in a contributing file, but I'll share a few now. 52 00:03:38,814 --> 00:03:43,680 It's best to include tests, every time you make a change to an open-source project, 53 00:03:43,680 --> 00:03:46,294 add a unit test to cover what you've changed. 54 00:03:46,294 --> 00:03:50,863 This helps maintainers know that the code does exactly what you say it does. 55 00:03:50,863 --> 00:03:53,180 Include screenshots if it's a visual change. 56 00:03:53,180 --> 00:03:55,234 This saves maintainers time so 57 00:03:55,234 --> 00:03:59,584 they don't need to test out your change in a variety of browsers. 58 00:03:59,584 --> 00:04:03,290 Always make your changes in the style of the project. 59 00:04:03,290 --> 00:04:07,308 Even though you may have a preferred way of solving a coding problem, 60 00:04:07,308 --> 00:04:11,600 or a certain style you'd like to stick to make sure your change fits in with 61 00:04:11,600 --> 00:04:12,864 the larger project. 62 00:04:12,864 --> 00:04:17,526 Now let's add a cross reference back to the issue that we created earlier in 63 00:04:17,526 --> 00:04:18,344 the course. 64 00:04:18,344 --> 00:04:24,139 Let's type a # sign, and find the issue we created in the last video. 65 00:04:24,139 --> 00:04:26,286 Once we find it we can click Enter and 66 00:04:26,286 --> 00:04:29,947 it will populate a link to the issue inside the pull request. 67 00:04:29,947 --> 00:04:33,250 If we use the phrase Closes #1 when this 68 00:04:33,250 --> 00:04:38,160 PR gets merged the issue will be automatically closed. 69 00:04:38,160 --> 00:04:40,960 Now all we need to do is click Create pull request. 70 00:04:43,020 --> 00:04:47,509 Now it's up to the maintainer to decide if they'd like to merge the changes that 71 00:04:47,509 --> 00:04:48,581 you've created. 72 00:04:48,581 --> 00:04:52,661 >> It's important to remember that not all pull requests will get merged. 73 00:04:52,661 --> 00:04:57,193 This doesn't mean your poor quest was bad or wrong, sometimes the maintainer will 74 00:04:57,193 --> 00:05:01,803 disagree with the approach or know about another change that's already underway. 75 00:05:01,803 --> 00:05:05,110 Submitting a pull request at all is a big accomplishment. 76 00:05:05,110 --> 00:05:08,600 So don't worry if your pull request isn't merged right away or at all. 77 00:05:09,770 --> 00:05:13,581 Well, that's it you're well on your way to becoming a GitHub pro. 78 00:05:13,581 --> 00:05:16,483 >> If you wanna check out even more ways to use GitHub, 79 00:05:16,483 --> 00:05:18,680 head over the guides.github,com. 80 00:05:18,680 --> 00:05:22,270 Remember, if you get stuck, you can ask for help in the Treehouse community. 81 00:05:22,270 --> 00:05:25,025 >> Thanks for taking this course with us, we'll see around Treehouse.