Up and Running with Git Transcripts
Chapter: Teamwork: Merging
Lecture: Merging two change-sets together

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Back on the Mac Developer one.
0:02 We've added our template rendering here.
0:07 We still have the older style,
0:09 the non re factored non split apart data layer but that's fine.
0:14 Everything's working. Remember we made some changes here that we could now push over here
0:19 So this but no pending changes but in this area we could do a git
0:24 push we could also do so with source tree.
0:28 We open up source tree, that one's gone.
0:32 We open up funny web. It says there's one thing to push notice also though
0:38 that source tree says there's two changes to pull.
0:42 Now I got to decide where is the best to show you this because PyCharm
0:47 is pretty helpful. I'll try to I'll try to do the pushing PyCharm.
0:51 What's going to happen is PyCharm is going to notice that there are changes on
0:56 the server and I think it will automatically try to do those.
0:59 So let's just do a push first and here and see if we can get the
1:02 error. We tried to do a push and it says your push was rejected.
1:07 Why updates were rejected because the tip of your current branch is behind its remote counterpart
1:14 that's kind of obscure. But let's look at the history.
1:18 What that means is, here's where the server is,
1:21 it's on origin main and this is where that Windows developer did their work and here's
1:27 where you are. You're on your main but you're too behind also one ahead.
1:32 So kind of odd in that regard.
1:34 Right? We've made some changes for the template that's one of our commits but we're
1:38 behind the work on the re factoring.
1:41 So you're not allowed to do your push to the server unless you are in sync
1:47 or ahead. Right. This bit has to basically be behind you the origin head
1:52 So you have to be at one point in sync with a server and then
1:56 only made changes on from there.
1:59 So how do we get these things synchronize how we get them working again.
2:03 This is where emerging comes in so I can press call here and behind the scenes
2:11 source tree will orchestrate having git do the pull and gets to do the merge but
2:15 let's try over here to do the push.
2:19 Just straight doing push because PyCharm will give us some better messages I believe.
2:25 It'll say the same thing. Your push was rejected,
2:31 your remote change the remote changes.
2:33 This is what the Windows developer did needs to be merged here on my machine,
2:39 you need to be emerged right here before I can even allow be allowed to push
2:45 those up. So what it's going to do is pull them down,
2:47 merge them and once everything is good,
2:50 it will then do what I've asked it to do.
2:53 So I'm gonna say remember and just do this silently in the future.
2:59 So if you push this button it'll say you may have to try to do this
3:03 Pull merge and then push your changes.
3:08 So let's do that. We emerge.
3:10 It's done. Hold the stuff down,
3:13 it says you've received two commits.
3:14 Let's see what those are finish the new data layer and set up.
3:18 Previous code execution. Okay, that's cool.
3:21 It took it a second for app.py to refresh for some reason.
3:24 But look now we have those changes automatically done.
3:27 Right. This is what windows developer did and this creation of this file is what
3:33 windows developer did. But we also have the changes we made.
3:39 So remember they change line three and line seven And we changed lines 12 and 13
3:47 We added this folder and this file,
3:50 they added this file and git was able to see all of those operations that happened
3:57 and basically decide here's how I'm going to reassemble that to take my changes plus those
4:03 changes without even asking. So that's pretty fantastic.
4:07 I guess one thing I would like to do before we move on is a quick
4:10 code cleanup. Let's go ahead and do a commit on that.
4:14 You can hit the hotkey and say just a little reformatting.
4:19 We don't have to look at errors and this time I can do a commit and
4:22 push all in one go and we're good.
4:27 Let's look over on the server.
4:33 Look, we've got finished data layer.
4:35 Re factoring just a little formatting,
4:37 added HTML. All those things are coming together.
4:39 We have now 10 commits now.
4:41 Normally you would see this across different people but because it's just me in different locations
4:47 you're gonna have to just imagine some of these are the Windows developer and some of
4:50 these are me over here on my Mac.
4:53 But that's it. That was really low key wasn't it?
4:57 We made our changes, they made their changes,
4:59 they created files, we created files,
5:01 we edited the same file. They pushed their changes.
5:04 We eventually pushed ours and PyCharm just said let's fix it up automatically for you
5:11 Source tree is a little more cautious.
5:14 It says you tried to push those things in.
5:17 We're not going to let you,
5:18 but if I push the pull the two changes it would do the merge automatically.
5:22 Then I could just push the other changes back up.
5:25 You will see that there's this merger of the remote tracking branch automatically done behind the
5:31 scenes for us by the tools when we did the pull and then the push pretty fantastic
5:35 Thank you. Git, thank you for letting us all work without locking files
5:40 and blocking things and just most of the time putting it back together for us. Pretty nice.