1 00:00:00,150 --> 00:00:02,230 So now we get to talk about pull requests. 2 00:00:02,250 --> 00:00:04,939 This is the first of a few videos on the topic. 3 00:00:04,950 --> 00:00:11,160 I'm just going to start in this video by talking about what poll requests or polls are and why we want 4 00:00:11,160 --> 00:00:12,300 them or why they exist. 5 00:00:12,300 --> 00:00:14,640 And then in subsequent videos we'll make our own. 6 00:00:14,940 --> 00:00:15,470 Okay. 7 00:00:15,540 --> 00:00:20,610 So we talked about this concept of working on branches and how that makes our life a lot easier. 8 00:00:20,610 --> 00:00:26,340 But then at some point somebody needs to merge those changes in from a feature branch into some main 9 00:00:26,340 --> 00:00:28,500 branch master, main, whatever, right? 10 00:00:28,500 --> 00:00:33,090 We don't just stay on separate future branches forever, otherwise everyone would be working in a silo 11 00:00:33,090 --> 00:00:37,740 and never merging and sharing their code, which defeats the whole collaboration thing. 12 00:00:37,740 --> 00:00:42,780 So rather than just allowing a free for all merge, especially if you're at a company where the stakes 13 00:00:42,780 --> 00:00:48,390 are high and you can't afford to screw up something on the main or the master branch, you have users 14 00:00:48,390 --> 00:00:54,060 you've got I mean, even if if not that, if you've got hundreds of developers and somebody includes 15 00:00:54,060 --> 00:00:59,370 some bad commit or something that breaks things on the main branch, at the very least, you've got 16 00:00:59,370 --> 00:01:04,920 100 something developers who now have a bad version of that main branch and they have to get rid of 17 00:01:04,920 --> 00:01:06,090 a commit or reset. 18 00:01:06,090 --> 00:01:12,000 It's just annoying and you want to make sure that whatever you are merging in or whoever is doing the 19 00:01:12,000 --> 00:01:16,320 merging has some discussion around it, has some approval. 20 00:01:16,320 --> 00:01:20,440 Maybe changes are made at the request of somebody else, right? 21 00:01:20,460 --> 00:01:27,360 There's some code review process involved and pull requests or peers are an integral part of that process. 22 00:01:27,360 --> 00:01:30,630 So pull requests are not a Native Git feature. 23 00:01:30,630 --> 00:01:35,550 They are built on top of platforms like GitHub and Bitbucket and some others. 24 00:01:35,550 --> 00:01:41,790 But really most people are referring to GitHub these days, but again, not exclusive to GitHub and 25 00:01:41,790 --> 00:01:44,730 100% not part of Git itself. 26 00:01:45,180 --> 00:01:51,210 So pull requests allow developers to tell other team members, other collaborators that they have some 27 00:01:51,210 --> 00:01:58,410 new work, that they want to be reviewed, new work that is on a branch that they want to be discussed, 28 00:01:58,410 --> 00:02:02,160 accepted a.k.a, merged in or rejected. 29 00:02:02,400 --> 00:02:04,290 And this facilitates discussion. 30 00:02:04,290 --> 00:02:09,479 They can get feedback, they can even update the work on the same pull request. 31 00:02:09,479 --> 00:02:14,340 So think of it as, Hey, everybody on my team, hundreds of people. 32 00:02:14,340 --> 00:02:19,140 I have this new branch with this feature I just completed, or I think it's complete. 33 00:02:19,170 --> 00:02:20,040 It's on GitHub. 34 00:02:20,040 --> 00:02:22,140 I'm making this request, this pull request. 35 00:02:22,170 --> 00:02:28,050 Can you take a look at it and somebody will you merge it in if it's good or will you tell me if it's 36 00:02:28,050 --> 00:02:28,710 not good? 37 00:02:29,100 --> 00:02:31,410 That's pretty much what a pull request is. 38 00:02:31,410 --> 00:02:36,150 So we do some work locally on a feature branch like we did in the last couple of videos. 39 00:02:36,150 --> 00:02:41,790 Stevie added the nav bar branch, we finished the nap bar, we push it up to GitHub instead of just 40 00:02:41,790 --> 00:02:45,360 merging that directly into Master or into Main. 41 00:02:45,660 --> 00:02:48,450 And a lot of companies, actually the main branch is protected. 42 00:02:48,450 --> 00:02:49,620 I'll show you how to do that. 43 00:02:49,620 --> 00:02:51,360 You can't just merge stuff in. 44 00:02:51,360 --> 00:02:58,050 You actually have to make a pull request so that there's an opportunity to discuss and accept or reject 45 00:02:58,050 --> 00:02:58,770 your changes. 46 00:02:58,770 --> 00:03:00,300 Somebody makes that decision. 47 00:03:00,300 --> 00:03:04,980 Maybe multiple people actually have to consent and and actually approve of your changes. 48 00:03:04,980 --> 00:03:09,480 So once you make the pull request, you then have to wait for it to be approved and hopefully merged 49 00:03:09,480 --> 00:03:10,770 or something. 50 00:03:10,770 --> 00:03:11,490 Discussion. 51 00:03:11,490 --> 00:03:14,700 It might be closed, it might be ignored, but hopefully not. 52 00:03:15,390 --> 00:03:17,490 So here's an example of some diagrams. 53 00:03:17,490 --> 00:03:18,690 I'm working on this feature. 54 00:03:18,690 --> 00:03:23,220 I finish it, I push it up to GitHub and I want to open a pull request. 55 00:03:23,220 --> 00:03:29,580 So on GitHub there's this new branch, my new feature, and you've probably seen this before, compare 56 00:03:29,580 --> 00:03:30,360 and pull request. 57 00:03:30,360 --> 00:03:31,590 It showed up a couple of times. 58 00:03:31,590 --> 00:03:34,380 When we push branches up, that is a button. 59 00:03:34,380 --> 00:03:38,670 I definitely want to click to make a pull request or I can also click it here. 60 00:03:39,270 --> 00:03:44,880 There's a couple of different ways of doing it, but if I click pull request, I then have this option 61 00:03:44,880 --> 00:03:45,600 to choose. 62 00:03:45,600 --> 00:03:47,670 What pull request am I making? 63 00:03:47,670 --> 00:03:54,540 Well, I am requesting that my branch, my new feature be merged in to Master or to main or whatever 64 00:03:54,540 --> 00:03:57,270 the default or it could be any other base branch. 65 00:03:57,270 --> 00:03:59,970 But typically we're talking about Master Main. 66 00:04:00,480 --> 00:04:03,260 So then I need to provide some information, right? 67 00:04:03,300 --> 00:04:07,410 I need to come up with a name for what my pull request is. 68 00:04:07,410 --> 00:04:08,850 What's the reason for it? 69 00:04:08,880 --> 00:04:10,140 What does it include? 70 00:04:10,380 --> 00:04:14,580 Depending on the company and the organization, there can be some pretty strict rules for what goes 71 00:04:14,580 --> 00:04:15,210 in here. 72 00:04:15,210 --> 00:04:18,450 And then I can click, create, pull, request, and then I wait. 73 00:04:18,450 --> 00:04:24,750 So in this hypothetical world of these slides, I have a boss and my boss is the only one who can approve 74 00:04:24,960 --> 00:04:27,810 changes, who can actually merge pull requests in on GitHub. 75 00:04:27,810 --> 00:04:33,330 There are different ways of configuring permissions and all of that that we can get into, but basically 76 00:04:33,330 --> 00:04:35,970 my boss has to accept my pull request. 77 00:04:35,970 --> 00:04:42,930 I, as just an employee, I actually don't have the ability to merge directly into master on GitHub. 78 00:04:42,930 --> 00:04:49,560 I'm supposed to make a pull request so my boss finds some issues and she actually leaves some feedback. 79 00:04:49,560 --> 00:04:53,010 She asked me to make some changes, ping me when it's ready. 80 00:04:53,010 --> 00:04:57,090 I can notify people or I can mention people in comments. 81 00:04:57,090 --> 00:04:58,770 I can attach files. 82 00:04:59,530 --> 00:05:02,230 She can even just close this out, by the way. 83 00:05:02,260 --> 00:05:04,270 Just close it without comment. 84 00:05:04,300 --> 00:05:06,790 No, it's a bit of a blunt way of saying no. 85 00:05:07,060 --> 00:05:08,560 Or she can just leave the comments. 86 00:05:08,680 --> 00:05:11,040 So then I can respond. 87 00:05:11,050 --> 00:05:13,110 We can have a conversation about it, right? 88 00:05:13,150 --> 00:05:15,850 I can say, okay, sounds good. 89 00:05:15,850 --> 00:05:17,530 I'll get to work on blah, blah, blah, blah, blah. 90 00:05:17,560 --> 00:05:21,380 Or I can say something like, Hmm, are you sure you really want me to do that? 91 00:05:21,400 --> 00:05:22,840 What's the motivation? 92 00:05:22,840 --> 00:05:25,310 Or I mean, I'm not sure I agree with that. 93 00:05:25,330 --> 00:05:27,490 What do you think, other developer? 94 00:05:27,490 --> 00:05:31,870 And then I can bring somebody else in and we can have a full discussion here as a team. 95 00:05:33,730 --> 00:05:40,150 I can even make more changes if she requests them, but then eventually, hopefully my boss decides 96 00:05:40,150 --> 00:05:41,410 things are good to go. 97 00:05:41,440 --> 00:05:43,530 It's time to merge those changes in. 98 00:05:43,540 --> 00:05:50,020 So if she accepts my request she can then go and click merge, pull, request and merge my changes. 99 00:05:50,020 --> 00:05:55,240 Or whoever is in charge of doing the merging, merge my branch in to the main branch, the branch I 100 00:05:55,240 --> 00:05:56,170 was requesting. 101 00:05:56,170 --> 00:05:57,810 And then we're good to go. 102 00:05:57,820 --> 00:06:03,490 So she'll click that button and then I'll demonstrate this for real, not just with slides. 103 00:06:03,490 --> 00:06:07,350 Then she can make the merge commit message directly on GitHub. 104 00:06:07,360 --> 00:06:14,290 So this is just a mechanism for merging changes in from a feature branch into some other branch where 105 00:06:14,290 --> 00:06:20,140 instead of just going for it, we have this process, we can have conversations, we can chat with each 106 00:06:20,140 --> 00:06:26,050 other, we can make updates, request things, we can reject a suggestion or a pull request or we can 107 00:06:26,050 --> 00:06:26,800 accept it. 108 00:06:26,800 --> 00:06:30,010 But if my pull request is accepted, the end result is still just. 109 00:06:30,010 --> 00:06:32,080 My branch is merged into another branch. 110 00:06:32,080 --> 00:06:39,790 It's just a slower, longer process that it's more transparent and more controlled, I guess, for merging. 111 00:06:39,910 --> 00:06:42,790 So that's an intro to the concept of pull requests. 112 00:06:42,790 --> 00:06:49,180 I'll wrap up by showing you that if we look at any popular repository on GitHub, there's going to be 113 00:06:49,180 --> 00:06:50,110 a section for pull. 114 00:06:50,110 --> 00:06:55,510 Requests like this is React, a very popular repository, lots of contributors. 115 00:06:55,780 --> 00:06:59,620 Those contributors don't just directly push changes up. 116 00:06:59,650 --> 00:07:04,750 They don't even have permission to directly push changes to any of the branches here. 117 00:07:05,140 --> 00:07:07,120 There's another way of making pull requests. 118 00:07:07,120 --> 00:07:10,600 We're going to talk about involving something called the fork and clone workflow. 119 00:07:10,600 --> 00:07:12,310 That will be coming up in a little bit. 120 00:07:12,310 --> 00:07:17,050 It's a common pattern to contribute to open source projects where you're not an actual collaborator, 121 00:07:17,050 --> 00:07:19,240 you don't have permission to push anyway. 122 00:07:19,240 --> 00:07:19,930 We'll get there. 123 00:07:19,930 --> 00:07:23,530 But if we go to pull requests, we can see quite a few of them here. 124 00:07:23,680 --> 00:07:29,230 And again, there's a lot of structure and patterns that have to be followed when you're creating a 125 00:07:29,230 --> 00:07:32,170 pull request for a big open source project. 126 00:07:32,170 --> 00:07:35,920 So they all follow particular naming conventions. 127 00:07:35,920 --> 00:07:38,290 They all have these different tags. 128 00:07:38,290 --> 00:07:43,540 But you can see here's one somebody wants to merge, one commit into master from their feature branch. 129 00:07:43,540 --> 00:07:45,250 Notice the name of this feature branch. 130 00:07:45,250 --> 00:07:50,920 Well, this is not a great one actually from depend, but if I find another one, how about this one 131 00:07:50,920 --> 00:07:51,460 here? 132 00:07:52,620 --> 00:07:55,950 So this is a pull request from the branch. 133 00:07:55,950 --> 00:07:59,010 Rick and Hanlon to. 134 00:07:59,040 --> 00:07:59,700 And Loney. 135 00:07:59,700 --> 00:08:00,570 I don't know. 136 00:08:00,900 --> 00:08:02,230 RH add effect. 137 00:08:02,250 --> 00:08:02,970 Warren test. 138 00:08:02,970 --> 00:08:04,100 That's the feature branch. 139 00:08:04,110 --> 00:08:05,820 Whatever he did on this branch. 140 00:08:06,150 --> 00:08:13,530 He wants to merge it into master and then we see some information about what his pull request includes. 141 00:08:13,950 --> 00:08:17,860 He wants to add a test so we can see under commits. 142 00:08:17,880 --> 00:08:19,360 Here's the commit. 143 00:08:19,380 --> 00:08:22,090 We can view that commit what's included, what's new. 144 00:08:22,110 --> 00:08:25,950 So some new code here and then there's a discussion around it. 145 00:08:25,950 --> 00:08:29,440 So this person said, please, they should probably throw an error like how? 146 00:08:29,520 --> 00:08:30,660 Blah, blah, blah, blah, blah. 147 00:08:31,320 --> 00:08:36,120 So there's a conversation, in other words, and this one is still open meeting. 148 00:08:36,120 --> 00:08:39,929 It has not been closed or rejected, but it also has not been merged. 149 00:08:40,020 --> 00:08:46,260 Oh, and there's a lot more conversation here around this PR and that's kind of a good place to end, 150 00:08:46,260 --> 00:08:47,600 just to show you an example. 151 00:08:47,610 --> 00:08:50,520 So these larger projects have tons of pull requests. 152 00:08:50,640 --> 00:08:52,710 Sometimes it can take a little while to get yours. 153 00:08:52,740 --> 00:08:57,270 If it's not super important, if it's not a critical feature you're working on, it can take a little 154 00:08:57,270 --> 00:09:02,130 while to get noticed, depending on the resources available to the project maintainers. 155 00:09:02,130 --> 00:09:04,790 Anyway, that's a basic idea of a pull request. 156 00:09:04,800 --> 00:09:06,720 I'll show you the workflow in the next video.