1 00:00:00,060 --> 00:00:05,130 So the first of these collaborative workflows I'm calling the centralized workflow, it's not really 2 00:00:05,130 --> 00:00:11,130 an official name or anything, but I'm telling you now it is the weakest it's the worst of these workflows 3 00:00:11,130 --> 00:00:12,270 for collaborating. 4 00:00:12,270 --> 00:00:18,180 And the reason I'm showing it to you is that the shortcomings of the centralized workflow are addressed 5 00:00:18,180 --> 00:00:21,090 by the other workflows that we're going to discuss. 6 00:00:21,090 --> 00:00:26,220 So we're kind of motivating the more complicated workflows, but we're starting with the simplest. 7 00:00:26,220 --> 00:00:31,470 So I'm calling it the centralized workflow, a.k.a everyone works on the master branch or everyone works 8 00:00:31,470 --> 00:00:35,700 on the main branch, or everyone works on some single branch. 9 00:00:35,700 --> 00:00:37,260 So that's why it's super easy. 10 00:00:37,260 --> 00:00:42,360 It's centralized because all the work is done on a single branch, whatever that branch is. 11 00:00:42,360 --> 00:00:46,650 Historically, that would just be the master branch, a default, but it could be any branch. 12 00:00:46,650 --> 00:00:48,600 So it's straightforward, right? 13 00:00:48,600 --> 00:00:53,880 We don't have to worry about pushing up a whole bunch of different branches and pulling them down and 14 00:00:53,880 --> 00:00:55,320 merging different branches. 15 00:00:55,320 --> 00:01:00,750 We just work with one branch, so I have some diagrams that I'm going to be using throughout this section. 16 00:01:00,750 --> 00:01:02,760 They all kind of follow the same pattern. 17 00:01:03,270 --> 00:01:10,530 Up top, we have three different collaborators, Pamela, David and Forest, and I'm highlighting one 18 00:01:10,530 --> 00:01:17,640 of them to indicate whose repository we're looking at on their local machine versus up top and the right 19 00:01:17,640 --> 00:01:18,030 corner. 20 00:01:18,030 --> 00:01:21,840 This is the GitHub repository that all three are using. 21 00:01:22,110 --> 00:01:24,960 So this is the same repo on GitHub for everyone. 22 00:01:24,960 --> 00:01:30,090 But then we have three different local repositories, but they're all connected to that same GitHub 23 00:01:30,090 --> 00:01:30,600 repo. 24 00:01:30,600 --> 00:01:35,220 And I have similar diagrams for the other workflows, the same characters, the same format. 25 00:01:35,520 --> 00:01:39,810 So with this centralized workflow, everybody clones the same repository. 26 00:01:39,810 --> 00:01:42,150 So this is our starting point, just one commit. 27 00:01:42,150 --> 00:01:44,630 So Pamela clones it down, right? 28 00:01:44,640 --> 00:01:47,790 There's the master branch or the main branch or whatever we want to name it. 29 00:01:47,790 --> 00:01:49,020 It's the same branch. 30 00:01:49,020 --> 00:01:55,170 So David clones that he gets that default branch master forrest clones the same GitHub repo and he has 31 00:01:55,170 --> 00:02:02,160 it so now they get to work forest this guy here at the mustache spends his day adding and committing. 32 00:02:02,160 --> 00:02:03,570 He's working on some new feature. 33 00:02:03,570 --> 00:02:07,020 He has two new commits, so this is what he started with here. 34 00:02:07,200 --> 00:02:10,919 He has two new commits worth of work on the master branch. 35 00:02:10,919 --> 00:02:13,950 So he wants to share that with everyone, right? 36 00:02:13,950 --> 00:02:17,070 He pushes that up so you can see those new commits. 37 00:02:17,070 --> 00:02:23,280 There's now three total commits on GitHub during this same period where Forest was working and he pushed 38 00:02:23,280 --> 00:02:24,030 his code up. 39 00:02:24,360 --> 00:02:30,660 Pamela has also been hard at work on her own feature all day, so that yellow commit is Pamela's new 40 00:02:30,660 --> 00:02:31,230 work. 41 00:02:31,620 --> 00:02:36,180 OC So as she's been working, Forest already pushed some code up. 42 00:02:36,180 --> 00:02:42,870 Pamela now wants to share her code with everyone, so she wants to push it up so she tries it get push 43 00:02:42,870 --> 00:02:50,220 origin master, but she's not allowed to y well she gets this message failed to push updates were rejected 44 00:02:50,220 --> 00:02:56,190 because the tip of your current branch is behind its remote counterpart merge the remote changes get 45 00:02:56,190 --> 00:03:00,780 pull before pushing again so git is telling her I can't do that. 46 00:03:00,780 --> 00:03:03,210 There are changes that you don't have on GitHub. 47 00:03:03,210 --> 00:03:08,070 You need to get those changes and merge yours with those changes and then you can push back up. 48 00:03:08,430 --> 00:03:10,620 So already we hit a roadblock, right? 49 00:03:10,620 --> 00:03:17,280 Just for Pamela to push her code up, she has to pull down everything that her other collaborators have 50 00:03:17,280 --> 00:03:17,910 pushed up. 51 00:03:17,940 --> 00:03:19,890 They're all working on the same branch. 52 00:03:20,070 --> 00:03:25,140 So if she does that, she pulls down, she gets the changes that forest had pushed from on the master 53 00:03:25,140 --> 00:03:26,130 branch from GitHub. 54 00:03:26,130 --> 00:03:30,450 Then she merges her work in and hopefully that goes smoothly. 55 00:03:30,450 --> 00:03:35,730 There might be a bunch of conflicts, maybe not, but she has to do it and then she can push back up. 56 00:03:36,330 --> 00:03:42,270 So now there are four commits up on GitHub or more, but a minimum of four. 57 00:03:42,540 --> 00:03:45,630 Although I didn't really include there would be a merge commit here. 58 00:03:45,630 --> 00:03:46,860 So let's say five. 59 00:03:46,860 --> 00:03:51,210 But whatever it is, she pushes up her new commits and she's good to go. 60 00:03:51,210 --> 00:03:51,420 Right? 61 00:03:51,420 --> 00:03:53,370 That's her part done for the day. 62 00:03:53,640 --> 00:03:59,520 Now, during all of this, poor David has been working on a new feature, but he's been having some 63 00:03:59,520 --> 00:03:59,910 doubts. 64 00:03:59,910 --> 00:04:00,960 It's not working. 65 00:04:01,590 --> 00:04:03,630 He's really like halfway done. 66 00:04:03,630 --> 00:04:05,700 He's deleted a bunch of important files. 67 00:04:05,700 --> 00:04:08,310 He's commented out some code, things are broken. 68 00:04:08,640 --> 00:04:12,360 So he wants to get some input, some advice from his collaborators. 69 00:04:13,020 --> 00:04:15,690 He wants to start a discussion and he wants them to see the code. 70 00:04:15,690 --> 00:04:17,550 They're not working in an office together. 71 00:04:17,730 --> 00:04:26,810 So he has this work and he has some commits indicated by this face this I guess I would call it a math 72 00:04:26,850 --> 00:04:29,970 face or a neutral face. 73 00:04:29,970 --> 00:04:30,570 I don't know. 74 00:04:30,570 --> 00:04:35,970 Anyway, he's not happy with it, but he makes it commit and if we're using this centralized workflow 75 00:04:36,090 --> 00:04:39,120 one branch, so he's just working on the master branch. 76 00:04:39,120 --> 00:04:45,570 So in order for him to share this, he can't just push it up because as we saw Pamela earlier tried 77 00:04:45,570 --> 00:04:48,000 and Git said, no way, you can't do that. 78 00:04:48,000 --> 00:04:51,210 You've got to pull down, get the changes, then merge and then you can push. 79 00:04:51,420 --> 00:04:59,310 So that's what he does before he can even share this mediocre, unfinished, broken code, he has to 80 00:04:59,310 --> 00:04:59,850 first. 81 00:05:00,080 --> 00:05:06,180 All down, get all the new changes and merge his broken stuff in his incomplete feature. 82 00:05:06,200 --> 00:05:10,930 He has to merge that in with the rest of the work everyone else has done on the master branch. 83 00:05:10,940 --> 00:05:15,470 Then he can push that up and now everyone can go and pull his work down. 84 00:05:15,800 --> 00:05:19,830 And he broke the code base probably if this is incomplete. 85 00:05:19,850 --> 00:05:24,640 Everybody now has that incomplete code and that's really frustrating and problematic. 86 00:05:24,650 --> 00:05:30,440 All he wanted to do is get some input and have some of his collaborators take a look at his work. 87 00:05:30,440 --> 00:05:35,900 But to do that with this workflow, he had to wreck the master branch, the one and only branch. 88 00:05:36,080 --> 00:05:40,160 So hopefully the problem is clear with those diagrams. 89 00:05:40,490 --> 00:05:41,440 It's simple. 90 00:05:41,450 --> 00:05:45,200 You don't have to think about where you're working if you're only working on one branch. 91 00:05:45,200 --> 00:05:48,950 But there are some serious issues, some shortcomings, first of all. 92 00:05:49,400 --> 00:05:54,740 Every person has to spend a ton of time resolving conflicts, or at least merging code, especially 93 00:05:54,740 --> 00:05:56,150 as team size scales up. 94 00:05:56,180 --> 00:06:01,280 Imagine you're working with, let's say, ten developers, and at the end of the day, everybody makes 95 00:06:01,280 --> 00:06:06,680 a bunch of commits, they push them up well for each one of those developers to make those commits and 96 00:06:06,680 --> 00:06:11,450 push them up, they first have to pull down everyone else's work just to merge their stuff in. 97 00:06:11,840 --> 00:06:17,830 So it's a lot of merging and potential conflicts, even if work is not entirely finished. 98 00:06:17,840 --> 00:06:19,710 So that brings me to the next piece. 99 00:06:19,730 --> 00:06:23,940 No one can work on anything without disturbing the main code base. 100 00:06:23,960 --> 00:06:27,190 How do you try some radical experiment? 101 00:06:27,200 --> 00:06:33,810 How do you try removing files and commenting things out, trying to fix some crazy difficult bug? 102 00:06:33,830 --> 00:06:37,720 If you have to work on the master branch, how do you experiment? 103 00:06:37,730 --> 00:06:39,460 And that brings us to the last piece. 104 00:06:39,470 --> 00:06:45,560 There's no way to really collaborate on anything unless you push in complete code up to master. 105 00:06:45,560 --> 00:06:50,210 And now all your other teammates have incomplete or broken code, which is what happened here in our 106 00:06:50,210 --> 00:06:51,410 final scenario. 107 00:06:51,440 --> 00:06:53,140 David wanted is this David? 108 00:06:53,150 --> 00:06:53,670 Yes. 109 00:06:53,690 --> 00:06:54,880 David wanted some help. 110 00:06:54,890 --> 00:06:57,550 He wanted to collaborate with, let's say, Pamela. 111 00:06:57,560 --> 00:07:01,770 For her to get that code, he had to add stuff onto master that's broken. 112 00:07:01,790 --> 00:07:02,750 Push that up. 113 00:07:02,750 --> 00:07:08,140 And now the whole code base is broken, at least at the tip of the master branch. 114 00:07:08,150 --> 00:07:09,800 Everyone else comes to work. 115 00:07:09,800 --> 00:07:11,840 The next morning, they get the most recent changes. 116 00:07:11,840 --> 00:07:14,690 Oh, things are broken for everyone. 117 00:07:14,690 --> 00:07:16,850 So not a good workflow. 118 00:07:16,880 --> 00:07:22,640 It can be manageable if you're a very tiny team and you're not doing anything experimental. 119 00:07:22,850 --> 00:07:27,260 Even then, I wouldn't really recommend it, but it is an option. 120 00:07:27,260 --> 00:07:32,660 So that really serves to highlight the problems with working in one branch, which now motivates us 121 00:07:32,660 --> 00:07:35,720 to talk about workflows that involve multiple branches. 122 00:07:35,720 --> 00:07:37,730 That's coming up in the next video. 123 00:07:37,730 --> 00:07:41,420 I want to demonstrate some of these problems for real using a GitHub repo.