Up and Running with Git Transcripts
Chapter: Teamwork: Merging
Lecture: Yikes! Merge conflict, now what?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's push our luck. Let's make some changes that are right at the heart of
0:05 what's going on. We did a code review and they said we don't want to
0:08 just import data, import jokes from data.
0:12 In fact we want to use data as a name space to make it super clear
0:16 where these jokes are coming from.
0:18 That's fine. We can do that.
0:19 So we'll say you know what import data which is cool.
0:23 And then down here we're just going to say instead of this,
0:26 we will say data.jokes.
0:29 Let's just be real good citizens and make sure this runs again and press F5.
0:36 Open it up sure enough we can still get a good joke about the bank.
0:40 Seems like it's working so we're ready to commit.
0:44 Let's go over here and push our changes in stage it this is gonna be something
0:49 to the effect of moved to data,
0:53 name space. That's cool. Gonna check that and sync those changes.
1:02 Great. Meanwhile over on the Mac we've decided we need logging,
1:09 logging please. So we're gonna come down here,
1:12 we're going to print out a statement that says starting to you know,
1:20 beginning to tell a joke like that.
1:24 And then we're going to print out the joke we are telling is and let's do
1:31 a little F string thing so we can format the string and PyCharm is an
1:35 awesome feature. If you hit this and you type something that will auto complete.
1:38 It will put the F back there.
1:42 That's pretty dope. Well let's just run that.
1:45 That seems good and if we look where it's running.
1:52 Look at this beginning to tell a joke the joke we were telling his relationship status
1:56 Let's do another one. This is how do you get the code beginning to
2:01 tell a joke down here? How do you get the code from the bank vault
2:05 Awesome. Looks like our logging works.
2:07 Let's go ahead and stop this and we're going to commit it.
2:12 So we'll go do this now.
2:16 It's a logging. Fantastic. We're going to try to do I'll just two steps
2:22 Let's do a commit wait that's local.
2:27 And then remember the Windows developers already pushed their changes so we're going to try this
2:32 and it's going to go probably go bang.
2:36 Perfect. You don't normally want to crash.
2:38 But this time I did so it says,
2:41 look, you both modify this file and as we saw it already tries to do
2:45 the merge. If you've modified one part that seems unrelated to another,
2:49 it'll give you a good shot at just doing that automatically.
2:52 But if it's too close, if it literally is basically either the same line or
2:57 the same block of code, git will say no no no no no no no
3:01 We're not doing this, you have to decide what happens now because I can't
3:05 fix this. So what I can do is I can either say,
3:08 you know what I'm always right except mine.
3:10 I just want to throw their changes away and be careful.
3:13 This will throw them away. they will be stored in history of source control but
3:17 they'll be gone or you can say what I did doesn't really matter.
3:21 Let's just take what they did.
3:22 I know that they're feature is important.
3:25 I'll just re add mine or it's not important or more likely you want to try
3:30 to merge those changes so we'll hit merge and check this out.
3:33 We get this really nice merge tool here,
3:36 but then shows us make it a little bigger.
3:40 It shows us your version. I said begging,
3:44 begin now whatever, we'll fix that in a minute.
3:47 We're begging to tell a joke apparently,
3:49 which is fine. So we have this change that we made down here,
3:54 right? And they've made this change that's like that.
3:58 So let's see if we can get these all to go together.
4:01 It might be a little bit too much,
4:03 we have to might have to type it.
4:05 But what we can do is at the top we can say look this,
4:07 I've made no changes here, this one,
4:09 this is all of them so I can press this button and it accepts that and
4:14 I do absolutely need that line to have data.jokes on it.
4:18 So I'm gonna try to do this and then I'm going to try to accept that
4:22 but it's probably going to wipe away that section.
4:25 Let's see. Be real careful here,
4:28 boom now it's said we took both changes and kind of jammed them together So now
4:35 the final bit, I'm gonna have to go,
4:36 you know what? That's why it could do it automatically.
4:39 So I'm gonna have to put that back together.
4:42 I do notice though that we get PyCharm's,
4:45 code highlighting and code checking. So if we have like data's,
4:50 it'll say we don't know what data is,
4:51 but like this, this lit up before when this was gone,
4:55 that was great out at the top and so on.
4:57 And so now you can sort of see it's helping us put it together in a
5:00 pretty rich way. Okay, so now we can say apply before I do,
5:05 let's bump over to source tree,
5:08 open this thing up and notice it's in this merge warning problem here as well,
5:14 but we can come over to the file status and it says problem problem,
5:20 we could go over and say resolve conflicts using an external tool,
5:24 mind there's restart, just say it's fine,
5:27 whatever, it's fine, whatever however it happens to be and so on.
5:31 I'm not going to do this in two places.
5:33 That's insane. But I just wanted to show you,
5:35 it also shows up over here now we're going to apply this,
5:39 this will tell git the merge is good and it will also save this file,
5:45 our push was rejected because we tried to push it up and it realized it needed
5:50 to do a pull first. It tried to merge it and it failed tried to
5:54 auto merge and that failed. So I just said stop,
5:56 stop, stop, stop you fix it,
5:59 you test it again and when you're happy then you can push those changes in,
6:03 we can see the commits that we received and we can actually see the changes done
6:08 by that person, right? They did this which is all super cool.
6:13 I think we fixed it though.
6:14 Let's go and run it again.
6:15 Just make sure it still works sure enough.
6:18 It does. So I think we're good,
6:20 let's stop over to commit. PyCharm is already remember we said now with logging
6:26 it's already locally committed that but I don't think it's pushed it.
6:30 Let's check Indeed it hasn't. So we tried to do this,
6:34 changing this change here which added our logging still annoyingly says begging,
6:39 I'll fix that in a minute and it says you have to do this merge which
6:44 resolved the conflicts in app.py Okay,
6:48 let's push our changes. Good to go.
6:52 We've made changes that were not able to be automatically fixed but no problem,
6:58 the tools decided that they couldn't quite make those changes for us.
7:02 So it did, its best it could.
7:05 It brought up some nice tools and showed us like here are the problems which do
7:09 you want to choose from them which do you want to choose from yours also really
7:15 quickly just so we don't go crazy,
7:17 let's fix beginning, commit and push and off we go good deal That was close
7:28 We had emerged conflict. We both wrote exactly in the same part of the
7:32 code, but we were able to see how to fix it and use the tools
7:35 to really support us along the way.