1 00:00:00,090 --> 00:00:03,650 When we rebase, we can end up with conflicts, just like when we merge. 2 00:00:03,660 --> 00:00:08,760 We're combining history, we're combining branches together that can lead to a merge conflict. 3 00:00:08,760 --> 00:00:12,540 So I'll just quickly demo that we are on the feature branch. 4 00:00:12,720 --> 00:00:16,890 Let's change something on our website file. 5 00:00:16,920 --> 00:00:26,130 How about I don't know, let's change this line that says Footer added Let's change it to say, What 6 00:00:26,130 --> 00:00:26,880 should we do? 7 00:00:26,880 --> 00:00:27,630 I don't know. 8 00:00:27,630 --> 00:00:32,700 How about how about this instead of log in for me, do log out form added. 9 00:00:32,910 --> 00:00:35,070 I don't know why you need a form to log out, but sure. 10 00:00:35,070 --> 00:00:40,950 And then instead of nav bar added let's do top nav bar added. 11 00:00:41,070 --> 00:00:43,470 Och not very exciting, but there we are. 12 00:00:43,500 --> 00:00:51,990 So I'm going to add that and commit and let's just go, let's say like update website on feature branch. 13 00:00:51,990 --> 00:00:54,810 I'm just putting on FT there so you can see it in the message. 14 00:00:54,810 --> 00:00:59,220 You normally don't say what branch you're working on in a commit message, but I'm just doing that here 15 00:00:59,220 --> 00:01:00,570 so that we can see it. 16 00:01:00,600 --> 00:01:03,720 Now I'm going to switch to Master, right? 17 00:01:03,720 --> 00:01:07,470 And I'll do some more work on one of these lines. 18 00:01:07,950 --> 00:01:13,260 So instead of saying top nav bar, I'll say, I don't know, main nav bar. 19 00:01:13,530 --> 00:01:19,020 And instead of log out, I'll do what should we say here? 20 00:01:19,140 --> 00:01:20,130 Sign up form. 21 00:01:20,130 --> 00:01:22,320 How about that sign up form added. 22 00:01:22,320 --> 00:01:24,750 So we should have some conflicts, right? 23 00:01:24,960 --> 00:01:26,940 And then we could even add something else. 24 00:01:27,150 --> 00:01:36,060 Well let's start with that get commit dash am or on the master branch update copy on master. 25 00:01:38,010 --> 00:01:41,850 So now I'm going to switch back to my feature branch. 26 00:01:41,850 --> 00:01:43,860 Let's do a tiny bit more work. 27 00:01:44,400 --> 00:01:45,300 Three. 28 00:01:46,490 --> 00:01:48,930 Get commit a m. 29 00:01:48,960 --> 00:01:51,890 Write more work on Ft. 30 00:01:54,740 --> 00:01:55,280 All right. 31 00:01:55,280 --> 00:01:57,830 So here's what our history looks like and get cracking. 32 00:01:57,980 --> 00:02:02,600 So we have a divergence if that's the right way of saying that. 33 00:02:02,960 --> 00:02:07,310 We have our feature branch, which has some work that's not a master, of course, quite a lot of work. 34 00:02:07,310 --> 00:02:09,350 But then master has new work. 35 00:02:09,380 --> 00:02:10,979 We'll pretend we pulled that down. 36 00:02:11,039 --> 00:02:15,980 We didn't just type that ourself because I would be very stupid what I just showed you in the real world. 37 00:02:15,980 --> 00:02:18,530 But whatever that work is, it's coming from GitHub. 38 00:02:18,530 --> 00:02:21,740 We pull it down, it's new feature our collaborators added in. 39 00:02:21,830 --> 00:02:23,240 I want that on feature. 40 00:02:23,240 --> 00:02:25,040 So I'm on the feature branch. 41 00:02:25,220 --> 00:02:29,960 I will rebase instead of merge, get rebase and then master. 42 00:02:31,020 --> 00:02:31,710 And. 43 00:02:31,980 --> 00:02:33,670 Oh, look at this output. 44 00:02:33,690 --> 00:02:34,900 Slightly different. 45 00:02:34,920 --> 00:02:35,250 Right. 46 00:02:35,250 --> 00:02:41,220 So it tries it recreates all of our commits from the feature branch, rebasing them on the master branch. 47 00:02:41,220 --> 00:02:44,760 But then it gets to this conflict. 48 00:02:44,760 --> 00:02:48,950 Merge conflict in website text failed to merge and changes. 49 00:02:48,960 --> 00:02:50,730 And if we look at our history. 50 00:02:51,240 --> 00:02:51,590 Hmm. 51 00:02:52,290 --> 00:02:53,250 Look at that. 52 00:02:53,280 --> 00:02:57,060 It is a partial rebase if you can see. 53 00:02:57,330 --> 00:02:58,320 I'll zoom in. 54 00:02:58,320 --> 00:03:05,100 So we have the feature branch which is here and it started to recreate our commit. 55 00:03:05,100 --> 00:03:08,160 So we have begin feature, but we also have begin feature. 56 00:03:08,160 --> 00:03:10,320 We have work on feature and work on feature. 57 00:03:10,320 --> 00:03:13,470 We have more work on feature, more work on feature. 58 00:03:13,470 --> 00:03:15,510 So the rebase is not done. 59 00:03:15,660 --> 00:03:17,040 So I have a couple of choices. 60 00:03:17,040 --> 00:03:18,960 One, I can just abort the whole thing. 61 00:03:19,530 --> 00:03:20,880 It tells me exactly what to do. 62 00:03:20,910 --> 00:03:25,950 Here we are to abort and get back to the state before run, get rebase, dash, dash, abort. 63 00:03:25,950 --> 00:03:29,160 But basically we are part of the way through rebasing. 64 00:03:29,310 --> 00:03:32,580 So it made new commits, some new commits, but it had a conflict. 65 00:03:32,580 --> 00:03:34,170 So we need to resolve that. 66 00:03:34,470 --> 00:03:38,460 So it tells us in this case it's just one file website text. 67 00:03:38,490 --> 00:03:44,910 I'll go in there and I have to decide what to keep, what not to keep, just like I would with any conflict, 68 00:03:44,910 --> 00:03:46,590 a regular old merge conflict. 69 00:03:46,890 --> 00:03:48,750 So what should I do here? 70 00:03:48,780 --> 00:03:56,280 Let's say I want top nav far, but I want sign up form so I can just manually do this. 71 00:03:56,880 --> 00:03:59,460 I'll do get rid of that. 72 00:03:59,460 --> 00:04:05,820 I don't want main nav bar, I want top nav bar so I can just manually reconfigure. 73 00:04:05,820 --> 00:04:07,950 I'm kind of just combining from two branches. 74 00:04:07,950 --> 00:04:12,420 I could have just gone with one or the other, of course, and often that's what you do. 75 00:04:12,420 --> 00:04:20,399 But in this case I'm going to manually just combine them so footer and then I want sign up form and 76 00:04:20,399 --> 00:04:21,899 then image gallery as well. 77 00:04:22,830 --> 00:04:23,340 All right. 78 00:04:23,340 --> 00:04:29,310 So it's kind of a messy way of resolving it, but that is the new version of this file that I want. 79 00:04:29,340 --> 00:04:29,820 Okay. 80 00:04:30,330 --> 00:04:33,240 So now it tells me, hopefully you can see this. 81 00:04:33,660 --> 00:04:36,450 What I need to do is mark them as resolved by adding them. 82 00:04:36,450 --> 00:04:43,290 So get add the file and then run, get rebase, dash, dash, continue, make this larger. 83 00:04:44,370 --> 00:04:48,240 So if I type get status it tells me rebase in progress. 84 00:04:48,240 --> 00:04:49,680 Here's the commit that it's on. 85 00:04:50,730 --> 00:04:53,610 It tells me exactly where it is in this rebasing. 86 00:04:53,610 --> 00:05:02,010 So I'm going to add website because I fixed the conflict in there, but I'm not going to commit. 87 00:05:02,310 --> 00:05:06,000 I'm going to run git, rebase, dash, dash, continue. 88 00:05:06,510 --> 00:05:09,870 So this is where you want to just pay attention to the output, right? 89 00:05:09,870 --> 00:05:11,490 We just follow the instructions. 90 00:05:11,970 --> 00:05:13,440 It says all conflicts fixed. 91 00:05:13,440 --> 00:05:20,550 Now run this or I can abort the entire rebase using dash dash abort if I just want to bail on it. 92 00:05:21,930 --> 00:05:25,680 So right now rebase is paused, but. 93 00:05:27,090 --> 00:05:27,870 I just continued. 94 00:05:27,870 --> 00:05:28,980 It looks good. 95 00:05:28,980 --> 00:05:30,300 Let's type get status. 96 00:05:31,050 --> 00:05:31,680 All right. 97 00:05:31,680 --> 00:05:32,880 We're going to re clean. 98 00:05:33,570 --> 00:05:35,760 And now we successfully completed the rebase. 99 00:05:35,760 --> 00:05:42,300 We resolve the conflicts, and the end result is that the changes from master and feature are all combined. 100 00:05:42,300 --> 00:05:43,050 They're integrated. 101 00:05:43,050 --> 00:05:46,040 So I have exactly what I wanted, right? 102 00:05:46,050 --> 00:05:50,430 I have this file resolved the way it is and the entire feature branch. 103 00:05:50,430 --> 00:05:56,700 All that history was rewritten on top of the master branch, rebased on top of the tip of the master 104 00:05:56,700 --> 00:05:57,270 branch. 105 00:05:57,750 --> 00:05:58,340 All righty. 106 00:05:58,350 --> 00:05:59,700 So we still can have conflicts. 107 00:05:59,700 --> 00:06:04,680 We're still just combining commits or combining branches, rather, and that can lead to conflicts. 108 00:06:04,680 --> 00:06:06,450 The way you resolve them is the same. 109 00:06:06,450 --> 00:06:09,270 You go into the files, it tells you exactly where the conflict is. 110 00:06:09,270 --> 00:06:14,940 You pick what you want, incoming, original change or a hybrid of them like we did. 111 00:06:14,940 --> 00:06:18,690 Then you add, you stage it, and then you follow the instructions. 112 00:06:18,690 --> 00:06:22,080 In our case, we don't want to merge commits so we don't do get commits. 113 00:06:22,080 --> 00:06:23,220 When we rebase. 114 00:06:23,220 --> 00:06:25,980 We did get rebase, dash, dash, continue. 115 00:06:26,460 --> 00:06:26,970 All right.