How to use GIT when working with a team?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome to akka and today we're going to be talking about git and how to work with it in a collaborative environment now we are making an assumption here that you have some basic knowledge of git so push pulling cloning and things like that and if you don't know where we're actually putting a video out for that and we'll go more into detail and in depth about how to use git as a tool but for this specific video we want to kind of lay a workflow on how to go about making branches using kind of thickening systems and how you go in the process of resolving merge conflicts or what your overall workflow is for using git in uh with teams right maybe you got a new job maybe start a new project and you want to kind of have an idea and a layout for how you want to use git so this video is for you if you have any comments questions or suggestions please leave them down below in the comments we'll be more than happy to take a look at them answer them because our objective here is for you to learn something here we have a github repository and we're going to work on this project one repo and the idea the mental framework that i want you to think is that you you know you got hired for a company and you're about to work on your first project or you're you know working on something personal and you bring other people in so what's kind of the workflow that we'll be using and what we want to do here is the first thing is we want to bring this code and we want to clone it or copy it to our local environment the way we're going to do that is we're going to copy that code copy that text there and then do on our local or on our terminal git clone and paste that whole link there that is going to bring all the files and everything from github onto our local environment now i'm going to go into that folder project one and as you can see i have the readme and the index.html the same as here so most of the time you will find that a lot of places use some type of system to keep track of the tasks that they have assigned and where they are right they're being done they're being worked on have they already been finished are they waiting to be reviewed et cetera so here we have a very simple kanban system where we have three columns what do we need to do what's in progress and what has already been done and we're going to take the ticket here number five and as you can see they have a number down here most of these uh systems will enumerate and give the ticket some type of notation here so you can keep track of them so we're going to work on this ticket updating text on html so what i'm going to do is i'm going to go here to my repository i'm going to create a branch so i'm going to get a checkout dashb like tix uh five right because working on ticket number five here you can call this uh different things most most of the times there'll be like a feature branch and you can have a little bit more details in the name or something as straightforward as you know the number of the ticket so as you can see now if you look here we have master and we have moved from master to ticket five so we have effectively created our branch here so i'm going to go inside of ticket 5 here and i'm going to [Music] open this in vs code the files are up here and we're going to work on this index file and we're going to change the body here to add a h1 that says hello world and that should be enough right we just wanted to update some of the text here i'm going to go ahead and close that out and now as you can see i'm going to do a git status and we will see that hey you modify the file so we need to go through the whole process of saving this and doing and committing it so i'm going to do git add i'm going to do git commit i'm going to pass in a message here i'm going to say number 5 is our ticket updated the text that's it now this has saved my changes or snapchat a snapshot of my changes to my local uh to my local repository to my computer here but i need those changes in that branch to be up in github so i'm going to go and do a git push dash u origin and then the name of the branch in this case our branch called tx-5 all right that's going to take a second and it's going to upload all my changes up to github so if i go here to code and we look at uh branches here and we also have this toast message top telling us hey you created a branch by the way so we have this text text number five branch that we just created and if i go into that we'll see that that is our branch and it was updated about 44 seconds ago perfect so now that we have all this before we go ahead and bring that code into master it's a really good habit that after you did git add git commit you want to do a git pull origin master and the reason that you're doing this is you want to bring any changes that have been made in master and you want to grab those changes and bring it into your branch so that way when you do a pull request you have no merge conflicts you have no issues and your branch is kind of up to par with master so now that they are good right we see that there is already up to date there's nothing else that needs to be brought in we're going to go ahead and make a pull request so we can do that here in the github ui in the github website so we're going to go ahead and pick our branch we can do with the tag up here or we can also go to the branch and do it here where it says create new pull request now this will create a new pull request you can put some information um added hello world here now you can put more details as needed not all pull requests will need a lot of detail some more some less and now we we have here the pull request is going to check right uh that output request is being merged into master correctly and that there is no merge conflicts so since there is no merge conflicts we get this green uh button here saying we're all good to go and it has like a double confirmation process now most of the time if you're not merging this yourself most of the time you're going to create that pull request you're probably going to share that with your team and then somebody on your team will look at your pull requests and make sure that you know you didn't maybe let a consul console log go through there or you forgot something inside of your code so that's the idea of pull request is you know another set of eyes to to make sure that the code is up to up to the standard of the team so once you were able to approve this and merge this this has been done as you can see it turns purple if i go back to my code now i'm looking at the master branch right you will see that this was updated three minutes ago and that the text is or the comment of the last commit message here is five number five updated the text so now we can go to our project here and go to our board now we can move our ticket from uh in progress to done right so that way here on our local since this was merged in and since we're making branches depending on the tickets we most likely are not going to need to open this ticket again or this branch again so we're going to go ahead and delete that so i'm going to go and check out to master so good check out master and this will bring me back to master and i'm going to get again all the changes where i'm going to get all the changes that are in my github repository and not on my local so since we just made a pull request here i need to go do a git pull and that's going to fetch all the changes and update master with those changes as you can see here index was updated and there were 18 kind of changes in there between deleted and added characters now that this is done i can do a git branch dash capital d for delete and then the name of the branch right and that was ticks five so the branch has been deleted now this has been deleted from my local branch this has not been deleted from the remote branch so that means if i come here the branch is still going to be there because i've deleted again on my local not on not on my github repository or my online repository so let's take a look also when you might get a conflict so here i have uh ticket number 10. i'm going to move it over from 2d to progress and we're just going to update the title and the text so let me go ahead and open this in my code editor and as you can see this is a file that we've been working with before i'm going to go ahead and just delete some of this text and i'm going to type in this is a test and below i'm going to also delete this text and i'm going to update to no conflict needed perfect and the last thing is i'm just going to use the title from will to echo and we should be good i'm going to go ahead and save this file and i'm going to go back to my branch here and i'm going to git add so i make sure like to take a snapshot of my code i'm doing a git commit m i'm gonna put a message here i'm gonna start with hashtag ten so we're talking about that specific ticket and then a little message you know what has been done now i'm gonna go and do git push dash u origin master because this is the first time i'm pushing this branch up to my github repository and once is uh once that is done that should be in github so we can now go ahead and take a look at this so we see here at the top that we have a compare and pull request is just the branch that we just pushed so now we see this red sign at the top saying we cannot merge this automatically and this is most likely due to a merge conflict now if you scroll all the way to the bottom you'll see that on the left side you have your master branch and on the right you'd have this ticket 10 branch and what's highlighted in dark green and dark red are the items that have changed on both branches let's go ahead and create a pull request and this will turn gray and it'll say this branch has conflicts we have to check them out we have to resolve them before we can continue so let's go ahead and first we're going to pull everything from origin master and this is going to bring us all the changes that are on our github repository on the master branch and we can see that there's a conflict here right it's a merge conflict and it's happening inside of the index.html file now let's go ahead and look at this insider code editor and we're going to see that at the top the dark purple would be what we just did at the bottom the dark blue color would be what's coming from master i can go ahead and accept both or i can accept one or the other in this case i'm going to take our current changes since that's what i would like to be in master please make sure you go ahead and save your file a lot of people tend to forget that and now we have to go through the same process of doing a git add git commit let's add a message here conflict resolved conflict resolution and then we're going to go ahead and push this up to github now again we're doing this because git adding a commit is taking a snapshot of our code and we have made changes to our code so that's why we have to go ahead and make the commit this will update the pull request and we'll see that this is good to go i'm going to go ahead and confirm this and now this should have been merged and has been merged into the master branch if i go ahead and check master we're going to see that the index.html has been updated i had two minutes ago right and now i can go ahead and check out to master and i'm going to pull which is going to bring all the latest code from the github repository into my local branch and i'm going to go ahead and delete this branch because we don't need it anymore we're working on tickets so when you get branch d ticket 10 and then that way we can delete it so working with teams the objective is going to be to constantly pull from master keep your code up to date this will help to avoid having to resolve very big conflicts and this is going to make your day-to-day a lot easier it's been a pleasure to help you out with this workflow let us know if you have any questions or suggestions we're going to try to look at them and answer them and give you a hand once again our objective here at ecco is for you guys to take something to learn something and we would love to help you in that journey thank you very much and see you on the next video
Info
Channel: Ako Dev
Views: 24,577
Rating: 4.9483871 out of 5
Keywords: git, github, development, ako.dev, ako dev, git workflow, team development, git within a team, practical git tutorials, git tutorials
Id: jhtbhSpV5YA
Channel Id: undefined
Length: 12min 16sec (736 seconds)
Published: Sun Sep 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.