git merge conflicts using vimdiff

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is Chongqing and today we're going to learn how to use vim death to resolve git merge conflicts we're in this directory under the feature branch and we've made some changes to the file and we're ready to merge we merge from master and we see that there's a conflict so let's take a look at that file we see that it has these markers and we need to go into the file and modify this manually or you could use a merge tool you can specify it this way you can specify jeev endeth we've use vim death or you can setup ie you can set up the configuration so you can say git config global merge tool cheap and it alright let's take a look right so we see a III we merge we have the working file and on the left you see the local file the local file is the changes that we've made on the right side we have the changes that we're trying to merge in to our code this is from master if we had just these two pieces of information that would only be a two-way merge but you need to have the base which is the file before any of these changes occurred so you can see what the changes actually were that were actually made for each of these and it will help a lot when we try to figure out what's going on so we're here in the working copy and the working copy has basically both versions of the file and so it makes the so it makes the death very very big so you can see these big open spaces so what I like to do is turn this off so when you turn it off it becomes a little bit more obvious what is going on at the top here you can see that there was nothing here before and I added the header on the master footer was at it so it becomes clear that we need to add both of these so let's go in here and turn this back on then turn it on by saying DIF T for diff this and let's just take the whole local so you can specify it this way or you can just shorten it to ello or you can say 2 because these buffers are are numbered this one this is 1 2 3 & 4 so if I do DIF get 2 I get this part it may help if you do DIF update to update the death anytime you make any changes it's good it's a good idea to do a diff update so we see that we need to add the footer so let's go in and grab the footer and we'll put it right here ok and then remember to do the diff update all right so before you another good thing to know is right bracket see if you do right bracket see it'll go to the first hunk and if you do a right bracket see you again go to the next one and the left bracket go to the previous so you can go jump from one to the other okay so we're done with this part now we're taking a look at the print file function and it's a little bit difficult to see what's going on here so here's the base and there's a lot of stuff that's going on so if you just want to see what changes were made what changes we made we could just turn this off and turn this off and you can see here that that the header was added and the line number is not there anymore so just take this out and put this in the other thing that happened was we added this with index so you can see that the line number has been been moved over here okay so that's what we did so let's see what the master did so let's turn this off and let's go to the remote which is the master and turn this on oops Dipti is to turn it on okay so we we can see here that really there the change is actually nothing because what we did was just a whitespace change we just got rid of these spaces so there's there was really nothing that happened here so we can just totally disregard this because in our version we got rid of this anyway so let's go back and turn everything back on so DIF T and DIF t okay so we can just from this section we can just accept everything from the local copy our changes okay so do a difficult date alright so now let's take a look at the next chunk which is right here and this is pretty obvious there was nothing there before and footer was added so let's just so we so that one is not a problem so let's go to the next one okay so in this one one thing that may be a problem is the coloring because it's using the the comic coloring and the comic coloring is this this gray and it doesn't look very good here so one thing that you can do is just change the highlighting so if you do death there's diff add this change delete and diff text so this one is actually diff text and you can see that it has a red background and right now it's ignoring the the foreground color because it's using the the font of the the syntax highlighting so that's just so we can just set that to a different color actually we can either set the foreground or the let's just change the foreground Oh actually if we change the foreground then it'll always be that color so we lose this syntax highlighting so let's just for now it's red but let's turn it to dark red so highlight death text we using a the GUI version so we say GUI BG otherwise you would use see term BG if you were using the console so you would say GUI BG and let's say dark red okay now that's a little bit more readable okay so it's we see that there are text changes but let's take a look so let's just turn this one off and so what are the changes that were made okay so let's just turn this one off okay so well first let's see what changes we made turn that off and we can see here that at the end we added this more comments so there was this addition of text so let's just turn this one off diff oh and go back here and turn this one on and we see that basically there are white space changes over here and there's this change just move this around here and I see this is not very obvious but just looking at this we see that this word has been removed so let's just turn this one back on and turn this one back on and let's just take one of these okay and so the first one which is the more comment and I'm going to apply the second one the second one we saw that there was the first first there was the indentation and this I'm gonna turn this one off because we had just applied this and what else do we need to do with this oh yes the this word was taken out see to it if update okay so that looks good and let's just turn this one off and just compare and we see that the difference between this one and this is that I added more comments and I kept the formatting okay so if we didn't if we weren't able to turn these diffs on and off it becomes very difficult so and you can compare between two different files either and comparing it to the base and just use the working copy to to gather the necessary changes that you need from wherever you need so that's pretty much it and after you're done you're ready to you you are ready to commit this but let's say for example that you've made a mistake you can do a git reset hard and that will bring everything back to the way it was and you're able to do a git merge because once you do a git merge you know get merge tool then you're not able to run it again because it think because all the all the all the files that were conflicted have been resolved so if you mess up then just do a git reset hard and start over so this has been the vended how to resolve get conflicts
Info
Channel: Chong Kim
Views: 33,676
Rating: 4.3925924 out of 5
Keywords: Git (Software), Vim (Software), Merge, Software (Industry)
Id: kFVjoIish0E
Channel Id: undefined
Length: 13min 39sec (819 seconds)
Published: Mon Mar 02 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.