Git Merge Conflicts | How Merge Conflicts Happen | How to resolve Merge Conflicts | Merge Conflict

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to ville AXA technologies in this video we are going to discuss about why March conflicts happens in the real world and how the developers are going to resolve the issues to demonstrate this concept I have created a github repository and also we have two developers who are going to work on the same repository at the same time so here I have a developer called a developer one as well as another developer called a developer two so this developer 2 is on AWS server another guy is on my on my Windows system now both guys are working on your same repository called merge conflict repository where I have created two files and if you see my info file and there is some information in this file so initially developer one has seen that ok this code doesn't looks good maybe it is text but usually in the real world we see the code red so he thinks that ok this code is not right there is some bug he want to update this code for that he is going to clone this repository okay so I'm cloning this repository so I'm developer at this moment git clone and I'm cloning the repository once you have cloned your repository you are going to get the repository and by default git branch if you check okay get branch if you check you have only one branch that is master branch usually developers doesn't work on the master branch they create a new branch out of that and they do the changes over there so let's take an example the time I'm creating a new branch called give to branch okay bill one branch okay because it is a developer one so developer one branch I am creating now we have created a new branch and if you check get branch now we have two branches so let me switch onto dev one branch and let me do my changes so get check out good check out is the command to check out to do branch so there one branch alright I have switched to day one branch and good branch if I check again okay you can see green color and star means you are into branch of course in my git bash I have updated so that I will get this information over here in which branch I am working fine so now let me do the changes to my file so VA my info and Here I am going to change my username to developer one okay so this is how I am fixing this issue and I am from Bangalore okay just updated this information and the gift status if I see so I have modified my info file on the day one branch so git add dot to git commit minus M updated my info file ok so I have updated our committed these changes into my local repository not into the remote repository once this is done I need to get status so nothing is there my branch is clean and I would like to commit these changes to the master branch ok but meantime one more developer has seen this code and even he thinks that ok this is not in the right format and if you see here it is still not yet committed as a developer one so he can still see the same code and he thinks that ok let me correct the bug so what he is doing he is also cloning this repository onto his system so git clone and cloning this repository and if I see I have merge conflict repository and he went inside and he would like to commit these changes so but he is working on master branch itself he is not creating any separate branch he edited my info and here developer - he has given and sit in him he might mentioned dill he okay so that's it and get status get ad dot git commit - em updated my info file developer - okay all right so I have committed my changes onto master branch itself and git push origin master so I'm pushing my changes onto remote branch it is asking for username so Rudy and I have given my password okay so what happened in this situation is dollar per $100 per to both guys has pulled same code and they updated the same file and same lines of code Burton dollar per one has taken his code and he created a new branch and he updated his code on the new branch and he is yet to commit his changes unto master branch once it goes to the master branch from master branch - he is going to push it into remote branch meantime dollar per to observed that okay there is some problem so he has cloned the repository and he committed his changes into the remote repository now currently it is two commits but developer two already committed his changes so it is going to update my info file and the three commits it came and if you see my info it is already updated okay now dollar per one he want to push his changes as well right so he is switching back git checkout master so he is going back to master and before pushing his changes he want to pull the code maybe he took some longer time and a few other developers might be updated the same repository so due to that he thought that let me clone the repository then let me merge my changes to the dev one branch to master branch so git pull so git pull is a commander to clone the sorry pull the repository so you can see here there were some changes and it pulled those changes in my info file there are four changes to lines I added and the two lines are deleted okay anyway he got latest code into the master branch at this moment and if I open the master branch my info file you can see here my name is developer - under I am from Delhi and if I check out get check out and do branch and I have switched to do branch and if I open my info file over here so you can see that developer branch changes okay now I would like to commit my changes unto the master branch usually whenever you want to commit your changes you should go to the destination branch in our case I want to commit my changes from day one branch to master branch so switch back to master branch again get checkout master and Margie were changes so get March and you were branch name so I want to merge the changes whatever is there in the dev branch you want to master branch okay you need not to specify the destination so if you do this one now you can see here Auto merging my info there is some problem with the my info it is trying to auto much the changes but conflict there were some conflicts in the my info file we need to fix those conflicts that is what it is saying LS if I open my info file cat my info you can see here your file has been updated and it has given the header nothing but what is the changes are same in the both of L's you can see here hello there is no conflict first line and the last line also I like movies but remaining two lines there is a conflict that okay my name is developer too and I am I am from Delhi and same way here also there is a conflict so now usually what will happen in the real world that group of people who has created conflicts or who has updated that code they sit together and they discuss which changes are valid to fix this particular issue and then they update the code according to their discussions and they push the changes so in our case dollar per 100 dollar per tool sorry sat together and discussed and come to a conclusion that okay let's keep the name as a dollar per one and keep the city from Delhi so like that they have taken addition and VA my info and we are updating according to the same discussion so my name is developer 1 and instead of my name is sorry I am from Bangalore I am giving I am from Delhi and remove this one also ok there are few tools which will help you to do this one but usually this is how we do ok if it is a smaller code if there is a lengthy code maybe you can use some third-party tools ok get status if you see now so we have updated our file now good status if I check sorry now git add dot ok next git commit - cm okay now git push origin master okay in master branch we are pushing our changes okay my changes got pushed into my repository if I go here and if i refresh it and new changes has been updated my name is developer one and I am from Delhi okay so this is how we can resolve merge conflicts hope this video helps thanks for watching and see you in the next video
Info
Channel: Valaxy Technologies
Views: 144,810
Rating: undefined out of 5
Keywords: aws, devops, valaxy technologies, security, automation, serverless, lambda, git, github, git merge conflicts, merge conflicts, github merge conflicts, how git merge conflicts happen, how merge conflicts happen, how to resolve merge conflicts, how to resolve git merge conflicts, git basics, devops realtime issues, git introductions, git for beginners, what is git, what is merge conflict, what is git merge conflicts, resolving git merge conflicts, git realtime, merge conflict examples
Id: nDRWhKc5Yd4
Channel Id: undefined
Length: 10min 28sec (628 seconds)
Published: Tue Jun 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.