Up and Running with Git Transcripts
Chapter: Teamwork: Merging
Lecture: Merging overview

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

Talk Python's Mastodon Michael Kennedy's Mastodon