git mergetool explained

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in this video I'm going to go through how to use the git merge tool this is where and just to kind of give you a little bit of background Eric had changed a file in his repository he hadn't done a poll and quite some time tim had also changed that file in the last few weeks and so when Eric tried to pull the code he got a conflict in this file and so what I have done is I've just gone in and typed to get space merge tool and that has brought this control up and it's basically showing me a bunch of stuff and so I'm gonna go through and show you how to actually merge this file and how to read what we're looking at so that everybody has the ability to do this in the future now the first thing is what we're looking at the the file up here on the top left is actually Eric's version of this file the file that is on in the middle is the base version which is the the file before Eric or Tim made any changes so this gives me a look at what the file looked like before either one of them made any changes the file on the right is Tim's version or the remote version that we're trying to pull into Eric's code and then down here on the bottom is what the thing is going to actually look like once the merge is done so what we're trying to do is we're trying to get the file down here on the bottom to look like we want it to look so that we can get this merged conflict taken care of so what we're gonna do is we're focused down here in the bottom so we are going to get in here and scroll down and take a look at what's going on so right off the bat we see that Eric did not make any changes to this line the base version shows that before Eric got the file nothing had been changed but Tim's version of the file actually has some comments in here and he's added this is employee thing to the top of it so we basically have the the extra code that Tim had added now if we look down here the bottom get already figured this out and it didn't really have a conflict here because Eric didn't make any changes to this particular line so it's already put Tim's changes down here into this code so this particular change is not a problem so we're gonna keep going down the list now this particular change if we look at this it had original code here now there is some meaning to the color codes and the basically what I think is going on here is this is blue because there absolutely was no conflict because there was no there was no code here this is brand new code you'll notice these are pink because there actually was a line of code here but you'll notice that Eric's version and the base version so this immediately tells me Eric did not change this particular fight this particular line in the file but Tim added an aunt employee or a and his employee to the end of it well again get figured that out because Eric didn't change the line so it's going ahead and merged in Tim's changes to that particular line so again everything looks okay for that particular line so now we're gonna go down to the next change so here we can see that in Eric's version of the file and the base version of the file nothing is really changed but over here we can see that Tim added a comment and he's got this if is employee that he's added to the beginning of that form so if we come down here again merge merge or figure that out to get merge tool figure that out and it has already added Tim's code to this line so we've got his comment and we have the if is employee and then the rest of it has just been bumped down some so again everything is still ok so now we're at this line we're gonna look here we've got this this is looking at status is less than 3 you'll notice Eric didn't change this line the base version didn't have that line change but Tim changed it again everything is okay because this matches what Tim did and everything is good so we're gonna keep going down here and this is the same thing Eric didn't make any changes Tim did change is done now here we have a head that's shown up now this is basically telling me where the actual conflict is so I could have skipped over all that other stuff and gone straight to where the head thing was but this is telling me where get is confused and if we look at this we can see why because Eric modified this line in fact he modified this entire block and has commented out the block of code while Tim has actually gone in and modified the block of code to do something different and and you can't really tell it here because the just because the width of the screen but if we do a ctrl W W and we move up here if we scroll over to the right we can see that Tim has added and and is employee which doesn't exist in the base version or in Eric's version so what we need to do first of all is we need to get rid of the head we need to get rid of these lines and the end of the conflict and now we're left with these two versions of the file this is Eric's version this is Tim's version now because Eric commented out this whole section it really doesn't matter what we do here but but just in case this gets uncommented at some point we're gonna keep Tim's version and get rid of Eric's version and so now the file matches the the final version that Tim had and the version that Eric had we still have our comment lines in here and we have our is employee so just to kind of finish up we're gonna go ahead and take a look at this next line this is a comment that we again do not see in Eric's code or the base version but we do see it in Tim's version everything has been merged in here ok and so there there are no more conflicts there and so at this point we've gotten rid of the head which you're going to have to do manually when you're doing this it just kind of highlights where the problems are and then we have merged tim's code into Eric's code and we've kept the comment and so everything should be perfectly ok now when we save out of here and so we're just going to do a shift ZZ and save that file and then I'm just going to do a quit on these other three at the top so that we're back down here to the the bottom so now if we do a get pull actually yeah do a get commit and so now we have committed the code and we fix the the conflict that we had
Info
Channel: Glenn Hancock
Views: 37,286
Rating: 4.2911391 out of 5
Keywords: git mergetool, git, mergetool, programming, merge conflict
Id: wxh-AOxPX_A
Channel Id: undefined
Length: 7min 4sec (424 seconds)
Published: Tue Sep 15 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.