Up and Running with Git Transcripts
Chapter: Teamwork: Merging
Lecture: Merging overview
0:03 Things are about to get exciting.
0:05 What we've done so far is cool and very powerful.
0:08 We've created our github repositories and cloned the git repo over to our local machine and
0:13 we've done some work on it,
0:15 we've used that to basically save our code to git hub to the cloud.
0:20 So now we have it saved somewhere.
0:22 And theoretically if it were public we could share it.
0:25 But now we're going to get into the first of the several teamwork sections.
0:30 In this one, we're going to talk about how multiple people.
0:34 Again, always want to say multiple people or people across teams that could either be
0:39 You and other people or that could be you at different points in time or different
0:44 locations. So it could be you on your desktop and on your laptop,
0:48 it could be you now and then you on a branch and so on.
0:51 So again, even if you're by yourself keep in mind there's still totally absolutely 100%
0:56 applies to you. So in this section we're going to talk about how do we
1:00 deal with synchronizing work across multiple people?
1:05 Again, we have our similar setup,
1:07 we have you on your computer,
1:10 your team members, open source contributors,
1:13 you and other points in time and so on.
1:16 And they've cloned the repository to their computers,
1:19 you've cloned it over to your computer,
1:22 they've done some work, you've done some work and now you want to say,
1:28 I need to get the latest source code from the server and by the way,
1:32 we haven't mentioned this yet, but in order for you to push your changes up
1:36 to the server, you absolutely have to be in sync with the server.
1:40 So even if your goal was only to push your changes,
1:42 you're still gonna have to synchronize with the differences on the server.
1:46 So you're gonna do a git,
1:47 pull what happens now? Well,
1:51 it really depends on what work you've done and what work your team member has done
1:55 Did you edit the same file or did you edit different files?
2:00 If it's different files, they'll just switch back and forth across each other and nothing
2:04 will, no one really noticed.
2:07 Right. Which is both files will now be edited on the server.
2:11 On the other hand, if you edited the same file,
2:14 how big of a problem is that traditional,
2:16 older centralized source control systems allowed you to lock a file so nobody could mess it
2:21 up while you're working on it.
2:23 That seemed like a good idea until somebody went on vacation and left it locked and
2:26 nobody could work for a week or it seemed like a good idea until you wanted
2:30 to work on something, you didn't have permission to like an open source project and
2:34 so on and so on. It's not good.
2:36 So what git does is say we're going to try to merge these together sometimes.
2:41 In fact, surprisingly frequently, it just works it out says you edited this function
2:48 they edited that function. There's no shared lines of code.
2:52 So they both get kind of merge together automatically and it's great.
2:57 But every now and then you'll run into conflicts where maybe you both have edit exactly
3:02 the same amount of code, the same location,
3:04 the code, and if there's two changes in the same place,
3:07 gets going to throw up its hands and say,
3:09 well, you you both wrote on the same line of code,
3:11 I can't decide who wins. So it's up to the person doing the merge in
3:16 this case you because you initiated the pull,
3:19 you're gonna have to figure out how to solve that.
3:21 So that's what we're gonna cover throughout this chapter.
3:23 How do we synchronize this work?
3:25 Seeing how GIT can usually do it magically on its own and if it can't,
3:29 what do we do about it?
3:31 It's going to be a lot of fun.