Git and GitHub Tutorial For Beginners | Full Course [2021] [NEW]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on guys assalamualaikum welcome to amigos code in this course i'm going to teach you about git and github if you are starting out your career as a software engineer and never heard about git and github then let me tell you that you as a software engineer git is something that you must know how to use like literally you must know how to use so git is a version control system that allows one or more people to work on the same code base on the same project for example you and i we could be working on the same project i can see your changes you can see my changes we can work on the same file if we have some conflicts we can resolve the conflicts and basically we have the history of the entire project as we build an application and then we have github which is the hosting platform that allows us to host our project somewhere on the cloud right so the most popular hosting provider for git projects is github but we also have big bucket get lab code commit and many others in this course we're going to start from the beginning understanding exactly how git works then we're going to touch upon commits working with branches creating pull requests resolving conflicts merging to master and then understand exactly how to use github so github is so nice it was actually recently bought by microsoft and they're doing an amazing job in terms of bringing out awesome features as you'll see throughout this course if you're new to my channel go ahead and subscribe also comment down below and let me know what is your level when it comes to use git right are you an intermediate or a beginner or expert so let me know whether you're an expert or not or maybe you've never heard about git and github so comment down below so this course is actually also available on my website if you want to gain a certificate i highly recommend you to take the exact same course but on my website without further ado let's kick off this course i always tell my students to practice as i teach so that that's the best way that you are going to learn and gain the most out of this course if there is anything that you don't understand please do let me know literally let me know and the easiest way for you to get in touch is by joining the community both private facebook group as well as discord so we are over 15 000 people combined already the community is huge and basically everyone is there learning how to code and everybody's super helpful so if you have any questions go ahead and post them on a group and we will help you also you can email me at hello amigos.com and i'll get back to you as soon as possible catch you in the next one let's understand how git works so usually when we write software we kind of have our working directory and this is where we have a bunch of files maybe you have a css file javascript containing some react code some html and pretty much you could have any other file extension within your project depending on the application that you are building now with git we have the staging area and we also have the commit history now the way it works let's say that we want to take the html file and then we want to represent that as a commit well the first thing that we have to do is to issue a command called git add so i'm going to show you git add in a second but here this is simplified and it's not actually html but html there represents to the actual file that you see there right so i'm just saying git add now before the file makes its way to the commit history it must go through the staging area and then once we are ready to commit the changes we say git commit and then it goes from the staging area to the commit history so basically this now represents the snapshot of our changes so obviously we could actually take for example this the javascript file and the css file as well and then issue the git add command go to the staging area and then have another commit now with commits we can have a bunch of commits so a commit is simply a save point so let's say that you have an application and you wrote a screen you can say right so this is working now i'm going to commit that change then you add a button and then you make that button when you click on the button maybe you want to get some data then you say right so this functionality now works let me actually create another commit and then maybe you change the css file so you've added some animation so on and so forth it works and then you say right so now let me also commit that change so a commit is simply a save point now all of this is actually happening within our local machine so we've taken some css files on javascript we added to the staging area by issuing the git add and then we committed those changes but all of this is happening in our local machine now the problem here is if our computer dies if our computer dies let's say that for example um the computer is not starting up right so now you've lost all of those changes well what we need actually is to take our changes and then store it in a remote server so a remote server where we can actually host our project the most popular git providers out there are github by microsoft then we have bitbucket and aws code commit and obviously we have others but these are one of the most popular ones out there now how do we take the changes from our local machine to the remote server so the way we do it is by simply issuing the git push command so now when we take the changes from our local machine we push it to a remote server if our computer crashes or we have any issues with our computer then the changes are in the remote server and what's really great about this is that now you can work and collaborate with people all around the world so let's say that we have josh from the united kingdom so josh has some changes that he wants to push to the remote server so it issues a git push and then those changes now from his laptop they go into this remote server and then let's say that we have miriam from egypt and now mariam can actually get those changes by simply saying get pull basically now mariam and josh they can basically work together on a project even though they live different parts of the world and this is why git is really powerful in terms of installing git in your machine it's really straightforward whether you are on mac windows or linux i'm gonna leave this link right here where you can read about it and basically they have the guides for installing on windows on mac as well as on linux right here so installation it's really straightforward and because i'm on a mac this is what i need to follow right here now for mac users the best way for you to install is using home brew so you say brew install and then git right here if you're on windows what i suggest you to do is right here i want you to use git bash so git bash so basically what git bash allows you to do is basically to have the exact same commands that i have so you can for example so if i make this bigger let's see on the screenshot right here you can have the same experience right here they say that it provides a bash emulation used to run git from the command line so make sure that you install git bash or you can install commander so commander is another great tool so cmder it's a great tool to get basically the exact same thing so i'm not going to install neither commander or git bash because i'm on a mac but if you're on windows go ahead and install those and i'm going to leave the link in the description of this video for this course we're not going to be using the graphical user interface client or gui client to interact with git and that's because i want to teach you git the right way so we're going to be using the black screen or the terminal or command line if you are on windows now luckily for you i do have a course specifically on the terminal and knowing how to use vim bash zsage and all of that good stuff so what i would say is if you're not confident using the terminal or command line then definitely take the terminal vim and bash essentials course first and then you can actually have a full picture of all the commands that i'm going to be showing you in this course however i'm going to make things super nice and easy for you to follow so even though if you don't have much experience using the terminal command line you can follow this course and if there is a command that you don't understand you can pretty much just rewatch the video again and then see whether it makes sense but as i said if you have any questions join the community ask us questions there and also i would advise you to take the course on using the terminal theme and bash because most of the times the best way for using git is through the tamannan command line because it's much quicker and everything that these gui clients gives you you can actually do it through your terminal and command line much quicker and as you become more experienced you realize that you will not use these gui clients that often so this is why i'm teaching you the right way because i want you to learn in the long term so that you become a badass developer once you have git installed the way you verify whether you have successfully installed git or not is by opening the terminal or command line so if you are on mac os go ahead and search for terminal and that should give you a black screen like my one or actually a wide screen but i'm actually using item right here so it provides a better shell experience and if you're on windows go ahead and search for cmd so cmd and if you have installed git bash so just search for git and then bash just like that so once you have things installed go ahead and open up your terminal or command line and by the way if you want to learn how to use the terminal command line go ahead and check my website where i've got this course right here so terminal and vim essentials and i pretty much teach everything that you need to know in order to be so comfortable with bashvim um basically everything that we're going to do here basically if you take this course everything will be so much easier for you and also knowing how to use terminal vim and bash it's a must for software engineers so in here the way that we check whether git has been installed we type get and then dash dash and then version so if this comes back with a version then you are good to go so if you are stuck go ahead and let me know send a message or on the facebook group or discord and we're going to help you but the installation process should be really really straightforward so also you can type git and then dash and then help enter and you can see that we have uh basically my font is actually quite big so let me actually make this smaller just like that and then just make it a little bit bigger now so let's see something like this and then put it in the middle oops not full screen uh let me just put it in the middle just like that and if i type git dash dash help you can see that now you can see much better so basically you can see that it's giving you a bunch of commands right here and we're going to learn how to use these commands in a second but this just ensures that i have successfully installed git and by the way i've just pressed so basically right here i've just pressed control so control plus and then l to clear the screen so ctrl l click the screen for me ctrl c ctrl l there we go so again if you are lacking experience on how to use the terminal go ahead and enroll to this course right here next let me go ahead and teach you how to configure git the first thing that we need to do is to configure git so that we have the right information about ourselves so the first thing that i'm going to do is to type git and then config and then dash dash global and then user dot and then name and here go ahead and type your name so for me it will be amigos code and then enter and also i want to write the email so here get config dash dash global user dot email and then the email will be hello at amigoscode.com enter now the last thing that i want to do is to say get and then config dash dash and then global and then color dot ui and then say auto this enables command line coloring output so enter and there we go so now if i clear the screen and then type git and then config and then press enter you can see that we have so if i scroll up so in here we have a couple of options so we have dash and then l for list all or dash dash list or we can also edit right so we can edit the information that we've just added so here what i'm going to do is i'm going to clear the screen so control l and then i'm going to say the exact same thing and then say dash and then l enter and you can see that this was the configuration so caller ui equals to auto user.email this is my email and user.name and right here this is amigos code and this one right here you don't have to worry about this was actually added by default by my operating system and there we go so now we have successfully configured git let me just press q to come out of this and there we go right so remember i said that we have the working directory this is where we have a couple of files so could be css javascript html and many others and all of this is in our local machine so let's go ahead and create the working directory and then have couple of files and then tell that the working directory should be a git repository and in git a repository is a collection of various different versions of a project that's simply what it is so let's go ahead and open up the uh shell so right here and what i want to do is i could actually go ahead and create a new folder and then here i could say learning and then dash and then git and then if i cd into desktop and then if i do one ls you can see that we have the folder right here but this is too long-winded so we should actually try and create things from the terminal so here i'm going to say make and then there and then learning and then dash and then get there we go and basically you find out ls you should see that we have the exact same folder here now what i'm going to do is within this terminal within this shell we're going to cd so change directory into learning and then get and i'm going to press ctrl l and then ls and you can see that this is empty right so right here we have no files inside now how do we tell that the working directory is a git repository so basically we have to initialize our directory so this is our working directory and we want this to be a git repository the way that we do it is simply say git and then init and then dot enter and now check this out so you can see that i actually have a plugin and you can see that it's basically things have changed in it's here me master i'm going to explain this in a second but now you can see that it says initialized empty git repository in and then this is the path right here and you can see that we have this dot git folder so basically in our local machine now we can start to issue git commands so we can say git and then add or git commit so on and so forth now what is interesting here is that if we want to work on an existing project we don't issue the git init so get in it is mainly for brand new projects so here we are creating a brand new project so if i type ls dash a you can see that i have this dot git folder so what i want to do is first let's say rm and then dash rf oops r and then f and then dot and then get so i want to delete that folder and you can see that now i don't have no longer basically um this is telling me that i'm actually inside of a git repository right so now if i clear the screen for a second if i type git and then add you can see that it says not a git repository now if i say git init and then dot so dot means the current directory now you can see that it has initialized the repository i can say git and then add and you can see that nothing specified nothing added maybe you wanted to say git add dot so basically now it's recognizing that we are inside of a git repository which means that we can start issuing some git commands this is how you initialize a git repository right inside of this folder so learning git let's go ahead and create a couple files so we're going to create a file called index.html we also want to create an index dot nnjs and we also want to create a let's say that this is i don't know the naming convention for css but main.css so now we have three files in there so if i at ls you can see that we have three files so index.html index.js and main dot css so basically these three files so now i can add these files to the staging area so that i can create a commit so in here the command i want to teach you is so let me make this a little bit smaller so we have a little bit more room to play with and bigger just like that so now you see everything so if i clear the screen so now what i want to say is get and then status so this is the first command that you have learned here so get status gives us the status of the changes that we have made so here you can see that we have on branch master i'm going to teach you about branches in a second no commits yet and then we have untracked files so here you can see that we have index.html index.js main.css and then it says that nothing added to commit button tracked files present use git add to track so basically in here so we have these files and we want to say git add to the staging area so now i can say git and then add and let's add index dot html enter and let me clear the screen once more and then run git status and check this out so now you can see that the status is a little bit different but we have now changes to be committed so now this is inside of the staging area and we can commit this so if you want to end stage here it says git rm so get rm dash dash and then cached and then index.html enter and i can now say git and then status again there we go and you can see that it's back to normal now i could say git add and then index.html and then git add index.js and oops i've missed a d in there so there you go and you can see that if i do a git status i have two files so and basically you saw that i had to issue two git add commands but what i can do is say git and then add and then i can say dot so dot means add all the files from this current directory downwards from this current directory downwards so if i press enter and then get status you can see that it added main dot css now let me go ahead and actually say git and then rm dash dash and then cached dot enter and i actually need to say dash r so it's fine there we go so basically had to do it recursively so it removed all of those files from the staging area and if i do a git and then status you can see that now nothing has been tracked so now i can say git and then add and then dot you can see that all of these files now git status have been staged so it's really nice now what i want to do is let's actually reverse all of this again so rm so git rm r cache and then dot and what i want to do is i want to make an endure and then i want to say test and i want to cd into test and inside of test i'm going to say main oh actually let's create a file so i'm going to say touch and then test.js so now have a look if i do a git and then status so you can see that it says right within so if i do an ls first i just want to show you that we have test.js but it says that we have four files which are untracked so what i want to do is i'm going to say git and then add so remember i said git add ads from the current directory downwards so currently i'm inside of test right and inside of test i have test.js so if i press enter and let me clear the screen once more and then if i do now git and then status you can see that i've only added the test.js because i'm inside of the folded test right so basically you can see dot dot so it's not going back a folder and then add these files so if you want to add every single file you say git and then add and then dash and then a capital a enter and now if i say git and then status and you can see that now all of these files have been added so i usually use git and then add dot so i know exactly what i'm adding into the staging area so so right now we've learned about git add and how to add things to the staging area also how to remove things from the staging area next let's learn about the git commit command so let's learn about git commit so i said previously that a git commit or a commit is a safe point so let's say that you build a feature or you write some code and then you get to a point where you say right this now can be committed so this is actually a safe point before i start implementing another feature so let's learn how to create one two and basically the commits you can have as many commits you want so right here let me go back and in here so remember we added so if i do get status you can see that we have all of these files right here all of these files in the staging area so also i'm inside of test folder and what i'm going to do is i always like to be at the root so cd dot dot and there we go so right now we have these three files inside of the staging area and we want to create one commit for all of these three files so the way we do it is say git and then commit and then dash and then m so here i'm going to say boot and then strap and then project if i press enter you can see that four files changed zero insertions and zero and you can see that we have a create mode and the files in here so now if i type git and then status you can see that we have nothing to commit and this is because we took the files from the staging area and then we created a safe point in here so how do we see the changes that we have committed well we can do in a couple of ways so in here let me clear this we can say get and then log enter and have a look so here we have the commit hash and this we'll learn about later but here this is master again later we will learn about this and then we have the author when we configured git so we added the username and email and then the date and then this is the commit message so we only have one commit message but if you want to see the changes that went into the actual commit is as follows i'm going to take this hash so i'm going to copy this hash command c or control c if you're on windows i'm going to press q and then i'm going to say git and then show and then paste the hash just like that and then enter and check this out so you can see that we have the basically we have the hash again the author date the message but here we have the diff so we have a new file this was the index.html we have the index.js main.css and then we have the test forward slash test.js so you can see that these were the files that went into this commit so now if i press q and what i'm going to do is i'm going to basically say vi and then i'm going to open let's say that we want to open index dot and then js and here i'm going to press i console.log and then hello git and then end up with semicolon press escape column and then wq so basically i've just modified the index.js so if i do cat and then index.js you can see that we have console.log and then hello get and you can also open this file with your favorite text editor and then just add this bit of information here so let's say git and then status you can see that we've modified index.js and what i want to do here is i'm going to say git and then diff enter and check this out so here it's saying that the death of what i have changed is i've added a line so here so get diff gives you the difference between what you have in the current working directory and what has been committed so let me press q there and now i'm going to say git and then add dot git status you can see that we have staged this index.js file and now let's create a commit so get commit dash and then m and then added console.log so when you have your messages make sure that the messages represent the actual change that you have made because the messages they must be readable to other developers so here press enter and there we go so you see that one file changed plus one insertion now if i click the screen say git and then log we have two commits so check this out so we have the latest commit which is added console.log and then we have the initial commit bootstrap project so if i grab the hash from the latest commit and then press q get and then show enter and check this out we actually get what has changed so before we didn't have any pluses here because we added empty files so if i was to remove as well you would see the entire history of this file so when you remove something it's actually red so if i press q and then if i say vi index.js and let's just delete escape column wq and if i do a git and then diff check this out this is now red because i have deleted this line so there you have it and if i do a git status you can see that we modified index.js what i'm going to do is actually say i want to discard the changes so to discard i'm going to say git and then restore and then index.js enter and if i do a gate status there we go nothing to commit if i do get and then diff nothing has changed there you have it you've learned about git commit how to see commits using git log and how to see the differences between your working directory and what has been committed let's go ahead together and change the main.css so ls you can see that we have the main css file in here and currently it's empty so here i'm going to open the file with vi and then i'm going to say main dot and then css and in here i'm going to press i for insert and i'm going to say body and for now this will be an empty body right here and i'm going to press escape and then column and then w key to save the changes now if i do a git status you can see that we've modified main.css let's add main.css so git add and then dot now let's go ahead and commit so i'm going to say git and then commit and then dash m for message and right here let me simply say some garbage message you can type literally anything so i press enter and you can see that one file change three insertions that's because we had three lines so now go ahead and type git and i've just pressed control and then l to clear the screen and now let's go ahead and type git log so here you can see that we have this commit so this was the latest commit and this was the the message right so this message really doesn't make sense and remember i said that the message should have meaning behind it right because someone will actually look at this and if they don't understand what your change is about then it becomes a little bit more difficult so the best practice is to have meaningful commit messages so let's say that we want to amend this commit right here so i'm going to press q and now i'm going to say git commit and then dash dash amend and then space dash and then m for message and now here i can say added and then body in main.css so this message now makes more sense and if i press enter you can see that now this has been updated and if i now do a get and then log there we go enter and check this out added body and then empty curly brackets in main.css so this message now makes more sense so there you have it this is how you amend a git commit message again make sure that your commit messages are well descriptive enough so far in our local machine we have a working directory with three files so the problem that we have here is that if anything happens to our computer whether the computer breaks or we have a virus or we lose access to our computer then we lose the project so we can't have access to the project so this is where we have the remote server so we want to store the project somewhere where we can host git projects so the way we do it is by using the get push command which you'll see in a second but what this does it takes a copy from your local machine and then it stores it into the remote server now remember i said that we have github we have code commit we have bitbucket but for this course we're going to use github for storing our git project so in a nutshell github is a platform for hosting and collaborating on git repositories so the idea is that we have a repository or a repo hosted by github and you often hear developers say a github repo or a git repository so basically it's a repository which is hosted on github and the cool thing about it is that we can then have people working and contributing to the same repository from all around the world github is awesome and it's my favorite platform for hosting git projects so what i want you to do is to navigate to github.com and right here you can see that they have this awesome landing page so github is so popular and you can see from the stats here they have 56 plus million developers 3 million organizations 100 plus million repositories and the numbers are just insane this is where the world of open source does live so everyone is using github and you should also use it so in terms of pricing so right here if you are student you actually get some perks so you can click on it you can see that you have the student developer pack uh for teachers as well classrooms so on and so forth but if i go back and then right here if i click on pricing again i can compare pricing or actually plans and here you can see that it's actually free right here and you can see that you can have uh unlimited private and public repositories uh you can have 2000 minutes of github actions and if you want to learn more about github actions go ahead and check my website where i've got a course on github action so this is really awesome when it comes to ci cd but most of the time you'll have a free one and then if you are working in a small team you know four dollars a month it's peanuts and if you're working in a company they're most likely using the enterprise or the github one plan so yeah so you can see a lot of people using it and right here you can also compare the actual plans so what i'm going to do is to go ahead and sign up and create an account and then i'll walk you through how to create a repository and then take our repository that we have created in our local machine and then host it in github right so once you have the account up and running you should see a page like this obviously if it's a brand new account it might not have all of this as mine but this is because my one has quite some activity and a lot of people are following me so you can see here and i also have some repositories right here so for you all of this might be empty so the first thing that i want you to do is to create a repository so click on new and then here the owner so this will be your username and then the repository name so here i'm going to say learning dash and then get then we can have a description it's optional and then here we can have the repository to be public or private so if you want to collaborate with people and you really don't care about the source code and anyone can can have a look at it then you can use public or if your application is private and you want to control who has access to it then you choose private so here i'm going to choose public because i want everyone to have a look at this repository and then here we have a couple of options here so initialize this repository with and then it says skip this step if you are importing an existing repository so what we are doing is importing a repository that we have created locally so here i'm going to say create and then repository and there we go so now you can see that we have this quick setup and basically um it's giving us some options here but what i want to show you is so remember in here we added this git in it before so if i zoom in here so git init remember and then we added some changes here so commit and then minus m you've learned about minus m and then here get branch and i'm going to explain branches in a second and then it says that this is how you push the repository so that's literally about it so in our case we don't have to do none of this because we already have the repository set up so all we want to do is just push so push an existing repository from the command line so here we need to do this and then we have to say get branch and then m and then push dash u and this is pretty much what we have to do so in our local machine we have our files and we want to push so we want to push the changes and all that's going to do is take our files and then put it inside of our repository that we have just created inside github so in order for us to be able to push first we're going to face an issue but let me show you first um what we need to do so in here let's go ahead and grab this command here so command c and then i'm going to go back to my terminal and here i'm going to paste so inside of learning dash git paste that and what i'm saying is git remote and origin so the remote for this branch is this path so amigos code so this is the username and then learning git is the repository so i'm going to press enter there we go that worked let me go back and here is telling me to say git branch and then minus m and then main so i'm going to grab this and right here the branch that we are currently in is master so github they recently changed the main branch to be called main instead of master so if i type git and then branch you can see that master is the branch so is this one right here now they recently changed so that the main so here the main is the main branch so a branch called main is the main branch so let's go ahead and paste that command oops not that one and let's grab this second one here and then paste there we go and you can see that now we have changed from master to main there we go from master to main and all we have to do is just say git push dash u and then origin main so if i paste this now i want you to be aware that this will fail so you can see that it says could not read from remote repository please make sure that you have the correct rights and the repository exists so next let's go ahead and configure our github account so that we can push to our remote repository so we tried to push to origin main and we got denied so what we need to do is so if i make this a little bit smaller so what we have to do is to configure the ssh keys in order for us to push to this repository so in here go ahead and you should see that we have you have your logo or avatar in here so click on it and then go to settings and in here you should see ssh and gpg keys so what we have to do is to basically generate a private and public key and then upload the public key in our account and then with our private key we can push to this repository so in here you see that it says there are no ssh keys associated with this account and we can check the guides on how to generate them so go ahead and click on this link and right here the instructions are very straightforward so basically um if i scroll down so in here you can see that generate a new ssh key right so let's click on it and then we have this page where we have installation process for both mac windows and linux so for windows users so in here make sure that you are using um git bash or a commander as i said before so here open git bash so either one of those and then you can follow these instructions here so here i'm on a mac i'm going to basically just open the terminal this is already open i'm going to grab this command so basically i'm just going to follow all these steps so it should be really straightforward so i'm going to paste this and change this to my email so here let's just say hello at amigos and then code.com and then press enter and right here i'm going to leave the default place where it's going to store the key now we are prompted to enter passphrase so here i'm going to skip this i'm going to press enter for no passphrase and you are more than welcome to add a path phrase i'm gonna press enter and then again enter and there we go so let me go back to the instructions again and in here this is what we've done and now what we need to do is to basically add your ssh key so here what we're going to do is just take this i'm going to take this and then paste that and then here so basically inside of the ssh config we need to add this so let me go ahead and simply say vi let me clear the screen so vi and then under tilde and then dot ssh and then config and inside i'm going to press i for insert and then paste that and then press escape and then column wq there we go and finally what we need to do is just grab this line and basically i'm just following step by step with you so that you see everything working so there we go so now this has been added so what we're going to do now is add the ssh key to your github account so let me just click on this link and it just says pb copy so i'm going to run this command and this will copy the key to the to our buffer so let me actually show you so if i um say cat and then tilde dot and then ssh and then id so that's the name of the key and then dot and then pub enter and there we go you can see that this is the key that we need to upload so obviously i could copy or i could run oops i've just pasted the wrong thing there but if i grab this so here if i cancel out this and then run pb copy enter now if i press command v you can see that it's on my buffer so i'm going to take that and then it says go to your youtube account and then you can add that within the sh key so basically this ssh keys and then you paste the key in here so here let me go back to github and again under ssh keys so we're going to add a new ssh key and then here let's just paste what we've just copied there we go and then add ssh key now for this we need to add the password there we go confirm and done and dusted so we are good to go so now next let's go ahead and try to push the repository again and see if it works at my terminal and in here i'm going to press ctrl c and then clear the screen and remember before so if i press the up error so before git push dash u or region main and if i press enter let's see if it works and there we go you can see that now it looks much better and right here you can see that we have to github and the new branch and then main main which means that if i go back to github so in here and what we're going to do is so i'm going to click on this logo right here and then repositories we can see the list of repositories we can search so for us was learning and then git so in here and if i zoom out just a little bit and there we go you can see that we have our three files and this folder right here which inside has the test.js and this is really really nice and remember before we added these commit messages so remember added body and then this when this was when we amended this commit and then added console.log so on and so forth so actually we've managed to take our files and then push them to github now let's create another file so i'm going to press escape and then go back so here we're going to create another file and here i'm going to say vi and then i'm going to name this as main.go so this is a extension file for golang and then press enter and then here let's just say for example let's just have an insert here and i'm going to say funk and then main and there we go so just an empty function in here so now i'm going to save this so escape and then column wq and if i do a git status you can see that we have one and tracked file and if i press control l now i'm going to say git and then add and then i would say main.go or i could just say dot now i'm going to add a message so i'm going to commit or actually let me just do a git status so you see there we go new file get and then commit dash m and then main oh actually added main dot go with empty main function cool now we've made the changes so if i press git log so you can see that we have added main.go with empty main function and this change so this change it's only in our local machine so in here if i refresh this page you can see that so i can see the commits in here so i'm going to click on it and you can see that there's no commits in here so now what i want to do is say git and then push so before we add dash u or region and then main so we don't have to do this because we already pushed the local repository to github and now we can just remove all of this and then just say git push so you know it knows what to do there we go so that's been pushed and now if i refresh check this out you can see that we have added main.go with empty main function if i click on this commit you can see this was the change and there you have it so you've learned how to push from local machine to remote where remote is github so we've learned how to take a copy of whatever files we have in our local machine and then using it push to copy them into github we also have the reverse which is taken from git so whatever it's in github and then pulling the changes into our local machine so currently what we have is we added a main.go file we've pushed it into github so you can see four files in each side so let's add a new file and then pull the changes to our local machine by using the get pull command so if i navigate to github and in here you can see that this was the previous page that i was on so i can click on this link right here which takes me to the main page what i'm going to do is right here you see what it says help people interested in this repository understand your project by adding a readme so let's go ahead and click on this file and here this is how we can document the purpose of this repository so here let's go ahead and simply say uh learning how to use git or actually this repo was used to learn git from oops and then amigos code and then delete that and right now if i scroll down you can see that we can commit this new file so basically these this is actually what's going to be added as the commit message and we can add this description so all i'm going to do is just commit the file and there we go so now you can see that we have a readme this is the title so learninggit so we could change the title as well and then this is what we said so this repo was used to learn git from amigos code so with readme's you can have check boxes you can customize make it beautiful link so on and so forth but for now let's just keep it simple so now you can see that we have five commits so if i click on it you can see that we have a commit in here 30 seconds ago and if i click on it you can see that this was the file added right so now in our local machine right here so if i press ctrl l if i do a git and then log you can see that we don't have that commit and that's because we need to pull the changes from the remote server ie github so to do that we can say oh actually before i i do that so let me do an ls you can see that we have these files so index.html css js js main.go and test folder so now i'm gonna do git and then pull i'm gonna bring the latest changes from remote enter and there we go so we actually have um some hints right here uh but i'm gonna ignore them and right here you can see that we have our read.md so now i can do an ls and let me clear the screen and check this out so we have the file right here so we've brought the changes so that was for a new file so let's go back to git and in here i'm gonna go back to the main page and then i'm gonna open up main.go and i'm going to click on edit and by the way you might not see these icons because and that's because i do have an extension that allows me to open from these ides so here i'm going to edit the file and let's say that oh actually not let's say but i actually forgot so let's say that we say package and then main just like that so this now is a valid golang application it doesn't do anything but now having the package main is valid so let me scroll down and here i'm going to say added package main and then commit the changes there we go so if i zoom out a little bit and then go back and in here you can see that we have six commits and added main so added package main so in here so if i do a cat and then main.go you can see that we don't have package main but if i do a git pull and there we go so if i clear the screen and then cat main.go you can see that now we have package and then main there you have it this is how to use get pull let's learn about branches so far we have a couple of commits uh that you have seen for example bootstrap project this was the initial commit then we had the other one which was to add the console.log we added another one for the empty body tag in main.css and we add another one for main.go and many other commits right so each commit remember i said it's identified by the hash so those random numbers that you see those are the hashes for each commit now all of these commits here they are inside of what we call a branch so remember when we pushed the project from the local to the remote repository on github we added this main branch and also main branch you'll see often on the internet called as the master branch so github they recently changed the master branch to be named as main but main and master branch they are basically the same thing so these branches they are the default branches and what is a branch in a nutshell so a branch represents an independent line of development so the cool thing here is that let's take the main branch and now if you want to work for example with me on this same project what you would do in best practices is create a branch named feature a you'd start development then committing a couple of commits so let's say that you commit uh or actually implemented the bubble sort then maybe you add a button for the screen and many other commits then once you are done with the implementation what you would do is merge you would merge your branch back into the main branch and again the main branch or master branch is the default branch so this is where the representation of the final snapshot or the final code is next let me go ahead and show you how to create a branch so in here you can see that my terminal actually tells me that i'm inside of the main branch so you might not see this depending whether you have the plug-in or not that i'm using and again if you want to learn how to use the terminal customizing all of this go ahead and check my course on terminal by shell and all of that good stuff so if you want to know the branch that you are on type get and then branch and right here you can see that it tells me that i'm inside of the main branch if you want to know the list of branches in the remote server so right because this command here only lists the branches in our local machine type get branch dash r for remote and you can see that we have origin and then main if i quit out of this we could also check all branches so get and then branch dash a and you can see that we have main and then also remotes and then origin and then main so this is the one on github if i press q there we go now if you want to create a new branch and when you create a new branch you're basically taking a copy of the existing branch and then you can make any changes in your branch without affecting main so let's create a branch so get and then branch and then feature dash a so make sure to use proper naming don't use like special characters uh nor spaces uh usually you should use like dashes or underscores and make sure that the branch name makes sense so here i'm gonna press enter and now if i do a and then branch dash a you can see that we have feature a in here so this is our branch now we created a branch but if we make any changes really we will be making changes in our main branch because we haven't switched branches so to switch branches we can say git and then check out and then feature a press enter and you can see that we have a message switch to branch and then feature a if you want to switch back to the previous branch git checkout and then dash so this will check out to the previous branch which was main so if i press enter you can see that it has switched to the main branch if i run the exact same command i should go back to feature a there we go and that's it so this is how you create branches so let's go ahead and create a new file so here we're going to say vi and then i'm going to say [Music] utils.nnjs enter and for now this will just have a to do here so to do implement utils escape column wq and there we go so now i'm going to say git status you can see that we have utils there so git add don't get commit dash m and then uh and then let me actually say just utils dot js with to do and then enter and there we go so now what we have is so if i do a git and then log you can see that the last commit in the main branch was added package and then main and then in here in our new branch you can see here feature a we added this new commit so you choose wait to do so if i press q if i switch back to main so git checkout and then main or this and then get log you can see that we don't see that commit that's because it's in a different branch so if i press q let's go back the feature a branch there we go now this branch currently is not in github so if i show you so in here so let's go to the main page of this repo and then check this out so here you can see that we have access to branches if i click on it you can see that we only have main which is the default right here and we can view all branches and fair enough there's only one branch now if i go back here for a second and then if i want to push this branch to remote type git and then push and then this will give you a nice command that you can just take just like that and then paste it or you can simply so instead of that you can say git push and then dash u the same way that we've done with the main branch enter and there we go so this now has created a new branch and you can see here new branch called feature a so if i go back to git and you can see that we have feature a right here so again if i now click in here on branches you can see that now we have this feature a so if i click on feature a you can see that this has basically the same thing right so this is the commit so utils.js with to do and if i go back to the main branch the main branch does not have that commit as its late latest commit so six commits let me go once more and you can see that here we have seven commits and there you have it this is how to create branches commit to branches so on and so forth one last thing i want to show you is let's go back to the main branch so get check out and then main and then git check out minus b and here what this does it creates a branch and then it checks out into that branch so before we did it in two steps so git branch and then we did a good checkout so here we're doing two steps so here i'm going to say to delete just like that you can see that we switch to this branch so this is what the minus b does so now if i do a git branch dash a you can see that we have to delete right here and if we want to delete this branch so let's just get check out back to main we can say git and then branch dash d for delete and then the name of the branch that we want to delete so to and then delete enter and you can see that deleted branch to delete so this is everything about branches next let me go ahead and show you how you're going to merge your changes from this branch right here called feature a into main branch i just want to touch on branches for a second so as you saw we are using the main as our default branch so as i've been saying through the slides most of the times or actually majority of the projects that you will see around so existing projects they will be using master as the default branch it was until recently that github decided to change the default branch to be named as main instead of master but main and master they are the exact same thing so if you are working for a company or when you join a company you will never push to the main branch or master branch directly you will never push to the main branch or master branch directly what you will end up doing is creating a branch making some changes pushing that branch to remote so you don't lose your changes and then you raise a pull request so that someone can reveal your changes and make sure that they are sensible changes right so making sure that you have the right amount of tests the logic is sensible and basically you're not doing anything that could cause an issue on the main system once it goes into the main or master branch so let's go ahead and explore pull requests right when it comes to merging two branches it's best practice that you do it through a pull request so in here you see that we have this feature branch and then we have the main branch now i could go ahead and say git and then merge feature a just like that and that would take the changes from the feature a and then merge into main branch so i'm not going to do this in here because as i said we should do this through a pull request so if i go back to github and right here you see that we have this message right here which says we have recently um created this branch called feature a and then it says compare and pull request so if i also go to pull requests and here i can see the same message and i can click on pull request and by the way if you don't see this message you can just go to pull request and then you can say right so you can pick the branch so feature a just like that and basically you can do this exact same thing so i can say create a pull request and then here i would give some description of what the change is really about and i'm going to leave it empty for now but it's usually best practice for you to have a description so that the person reviewing this change knows exactly what you're doing and then you can see the changes in here so obviously we just have one file but obviously we have one file with one tiny change but if you're working on a big project then you should see you know many files many deletions changes so on and so forth so now i'm going to create a pull request and there we go so now we have a pull request so this is very important so in here you can see that we can merge i'm not going to do it i'm not going to do it now but you can see that we have reviewers so in here reviewers so this is for example where you would choose a person which is working on the same project as you to check whether your changes are good to be merged into the main branch so obviously no one is here because i haven't invited anyone into this project but if you are working for a company then you should see um reviewers that you can pick from then in here we have uh actually assignee so this is yourself we have labels we can have uh labels for example um enhancement or question um let's say that this this was a bug for example right that we were fixing there we go we have this you can also add projects so project and milestone so this is about project management and then issues as well and also here checks so for example if you are using github actions you want to make sure that specific checks have to pass before you merge the pull request then you can do it so in here you see that we have this button and i can merge it in ideal scenarios someone would actually need to approve this change before you merge the pull request and all of this can be configured through settings in here so i'm just going to skip all of that and just say you know what i think these changes are sensible so i'm just going to merge them so i'm going to confirm the merge and there we go now what i'm also going to do is delete this branch and you can always restore if you need it so now if i go to the main page or actually code in here you can see that it says amigos code merge pull request and now we have eight commits so if i click on commits you can see that this was the change so utils.js and then you can see that i've merged this branch so if i click on either one of those there we go you can see the change that went in and we are good to go so let me just go back in here and if i go back to my terminal so if i clear the screen and then do a git and then log and here i'm going to say dash dash one and then line so this is a new flag that you've that that you are learning enter so this basically um gives us a much better syntax so you can see that we actually don't see the changes that we've merged to main and that's because we need to pull so if i do a git and then pull there we go you can see that utils.js one file has changed and if i clear the screen git log dash dash one line there we go so you can see that i do have the same thing that i saw on github so this is nice and also i can go ahead and delete the feature a branch from my local machine so i've actually deleted in in the remote server but i can also go ahead and delete so get branch and then dash d and then feature a enter and then git branch dash a and there we go so this is pretty much how you should be merging your changes and pull requests right let me walk you through your workflow when it comes to working with git so the first thing that you should always do is if you're working on a new feature let's say that you are working on a new feature then the first thing that you should do is pull the latest changes from master so pull the changes from the remote repository right pull the latest changes from master down to your local repository or to your local machine from that point you create a new branch so git checkout minus b and then the name of the branch at that point you then start working on a feature a bunch of commits so on and so forth and off you go now is advisable it's advisable for you to rebase your changes against masks especially if you have been working on this feature for let's say a day or two as you know master will move on right so master will move on so what you want to do is to bring the latest changes from master into your local machine right and when you rebase you might or may not have conflicts if you don't have conflicts that is absolutely fine right so no issues there but if you have conflicts then you have to resolve all of those conflicts right so as i as i um told you about if you have 10 commits then you have to resolve the conflicts for each commit so what is advisable for you to do is to squash all of your local commits first and rebase master so you squash your commits right and then in your in your branch you have one single commit and then when you rebase you say right so this is my commit i'm gonna remove this commit so this action is actually called stash in git i'm going to stash my commit i'm going to put it aside bring all the changes from master or main here and then i'm going to try and bring my commit back on top of it right so if you have one single commit then you have to resolve the conflicts once and you're good to go so then what you do is you push to remote and then you raise a pull request you have discussions with your peers and if the changes are approved then you merge your commit into the main or master branch and that's pretty much what i do on a day-to-day basis if you have any questions drop me a message otherwise let's move on right let's go ahead and create a new branch so here i'm going to say git and then branch and then feature and then dash x y and then z or better we can say git and then check out minus b and then this will create and check out this branch so now let's open up the index.html so if i do an ls you can see that we have index.html and currently if i do a cat and then index.html it's actually empty so there is nothing in it so what i'm going to do is navigate to w3schools.com forward slash html and in here i'm going to grab this html right here so you'll find this also in the description of this video so i'm going to grab all of this and we could actually use vi to edit the file so i could say vi and then index.html but let me just open up vs code so you can see things easily so right here i'm going to open the folder and then i'm going to navigate to desktop and inside of desktop we have learning git and open so there you go now you can see that index.html is actually empty so let's paste all of that code right here and what i'm gonna do is the following so let me just remove all of this for now so the body so you saw that we have taken this right so we're going to basically have an empty body for now save that and we could actually commit from here or from the terminal so let's say git add and then dot and then commit git commit dash m and then add some html and here i'm going to say git push so this branch now will be in our remote repository there we go so if i go back in here and then in here you can see now we have this branch now what i want to do is let's say that you so you will make some changes to this price so let's say that you and i are working together on this exact same branch so now i'm going to pretend to be you so here i'm going to open up this branch right here and if i open up index.html you can see that it's empty the body is empty now what i'm going to do is i'm going to edit this file and then here i'm going to say inside of the body i'm going to paste oops not that but basically what i want to paste is so in here i want to grab this and then go back once more and then paste that in there we go so we have this is a heading and this is a paragraph right so now i'm going to commit but let's say that this is actually you making these changes so there we go now in my remote branch i'm i'm not aware of what is happening right so in here you can see that for me this still empty right so one way i could do it is actually pull the changes and then i would see the heading and paragraph but let's say that now so this is me now i'm going to basically in here i'm going to say this is a another paragraph so i've just saved that right so you can see that now we we actually have a conflict because you so you have made these changes i haven't pulled down those changes into my branch right and in the same place so line seven i've made some changes so now we are going to have some conflicts so let me actually show you so now in here what i'm going to do is i'm going to clear the screen so ctrl l or clear there we go now i'm going to say git and then add and let's commit this so here let's say add and then oh actually added and then p one oh actually another p tag and then enter and this is what i'm going to do so now so if i say git and then push and now you can see that this actually failed so it says updates were rejected because the remote contains work that you do not have locally so this is usually caused by another repository pushing to the same ref so basically you have pushed these changes i didn't pull and now i try to push my changes right so here so this is another paragraph and basically now i can't do it because i don't have those changes locally so next let's go ahead and pull those changes and see what's going to happen right so as you see we need to pull before we push our changes so let's go ahead and say git and then pull you can see that we have basically in here so we have auto merging index.html because we both made changes in it and then you can see that it has detected a conflict and then it's trying to merge so meaning that it's trying to take my changes take your changes and then put those changes together but it actually failed to do that and it says fix conflicts and then commit the result so here what i'm going to do is open up vs code and check this out so now we have this strange thing going on here and in fact let me actually show you that so if i click the screen in here and then if i do a vi and then index.html and in here you can see that we have the exact same thing so this can be a little bit confusing but let me explain so this part right here so head and then this part right here so these are our changes so remember locally we added this is another paragraph we tried to push that but we had a conflict and the conflict that we have is that in remote so in remote and let me make this bigger right here so in remote so you made these changes right so this is a heading this is a paragraph right here so this is a heading this is a paragraph and this is the actual hash right here so f8 and you can see that if i click on this number right here so the commit so this is the um smaller version but if i click on it so in here check this out so you can see that commit and then basically this is the exact same hash that we have and if i copy that go back command f command v you can see that is the exact same thing so now we have to fix these conflicts before we can merge and to do that we basically remove these um where things in here so these less than signed and then the head and then basically we fix all of this and then push so let me actually do it through vs code so in here uh you can see that vs code is actually nice because it's telling me that so here incoming change right here so this is what was made in the remote branch so this was um made and then the current so this is the current change that we have so this is another paragraph so this is what i what i've just explained so we can accept the current change accept incoming change both and we can compare so let me just show you that right here if i delete that so i'm going to delete that and then i'm going to take this right so i'm going to cut this because i know that my paragraph has to come before maybe has to come before or actually has to come after or maybe before but in this in this case i'm just going i'm just going to add it after this paragraph that you added so now i can say s for save and there we go so now we have fixed the conflicts so now we have to stage and then we can push it but let me just go back in a second so i just want to go back in here because i want to show you that here i could say for example accept both changes so here and you can see that it actually um fixed that for me right but i actually didn't want this in here so i want it right after the first paragraph so this one here and there we go so let me save this and let me go to my terminal now and we could do this through vs code but in here let me just press column and then q and then exclamation mark to exit if i do a git and then status in here we have and merge paths so both modified index.html so what we need to do now is just say git and then add index.html or dot so we can say dot as well so everything and basically you can see that it's telling me that i need to add the file or files to mark resolution so that's what we've done so if i do a git and then status again it says changes to be committed so let's just say get commit minus m resolved conflict and if i do a gate status again you can see that nothing to commit and now let's say git and then push and you can see that this time it works so if i go back in here and go back here as well and now if i refresh you can see that we have our change in here so this is how you merge conflicts so obviously in our case we only had one change but if you have many conflicts then you're gonna have to resolve all of those changes manually or you can use vs code for example to help you resolving these conflicts much faster right let's understand what rebase is so if you're working on a branch so you have a branch right so remember when you say git checkout you should really be checking out from the main branch may have multiple commits right so now you are in a scenario where the main branch has moved on and you don't have the commits from the main or master branch right so what rebase does it says right i'm going to bring all the changes from whatever branch that you want i'm going to bring the changes right and the changes will be underneath your your new branch right so basically it says right i'm going to take all of your commits away i'm going to bring all the commits from master into your branch and then i'm going to try and apply your changes on top of it that's what rebase does so let's go ahead and explore rebase in detail right so to demonstrate the rebase functionality with git let me go ahead and in here so remember we have this branch that we created so this was feature and then xyz so now let me go ahead and open up the main branch so here let's go to the main branch or master and this is empty because we haven't merged our branch so if i go back or in fact let me just go to pull requests and you can see that we have this branch that we haven't merged right so that's why in master so main so main so let me actually go here so you can see so here so the main branch doesn't have those changes so let's commit straight to master from here and i want to show you something so again i don't advise you to do that because you shouldn't really be committing to master directly and also using github but for demonstration purposes let's go ahead and do it so here i'm going to open up index.html and let me open up my terminal and in here i'm going to clear and still in feature xyz i'm going to say cat and then index dot html and here we're going to grab all of this in here so also you can grab from vs code so here now what i'm going to do is i'm going to edit from here so let's say that we have another developer and he already went and made these changes right so he already made you know the html page and let's say that he added and then here i'm going to say first and then paragraph and now i'm going to commit the changes and there we go so the main branch or the master branch contains already these changes right and in our branch so if i click in here so this is main let me open up again you can see that first paragraph so this is already in main or the main branch so in here in our feature xyz if i click on it and open up index.html you can see that this contains and h1 and then two paragraphs so in here how do we go and say right we want to we want to take the latest changes from the main or master branch and then add our changes on top of it so this is what rebase allows us to do so here i can say get and then pull and then dash dash rebase or dash r and then origin and then main so main is our main branch but often you'll see also this master right so the master branch but in our case we are using the uh main branch as our default branch so now if i press enter you can see that it tried to bring the changes from main and then it tried to add our changes but you can see that it says conflict and then merge conflict in index.html and then error could not apply and we need to resolve these conflicts manually so again we've learned about conflicts so here if i go back so this now is familiar right so um basically this was already in main so these were these changes were already in main and then we have in here so this actually is our first commit to this branch so what we're going to do is we're going to say that we basically want to take whatever it's in main so i'm going to say accept current change and save this and let me delete that line there and now in here oh actually in here you can see that i can say stage changes but let's do it through here so this is better so here i'm going to say git and then add and then it says git rebase oh actually git rebase and then continue once we resolve the conflicts so git rebase dash dash continue and here we basically have the commit message so i'm going to say so i'm just going to leave it as is i'm going to press escape column wq and there we go so still we can't do it because we have another conflict so this is now the second commit and right here if i open up vs code you can see that this now is complaining because we added this is another paragraph so what i'm going to do is i'm going to merge these manually so here like that and this should be like that save and we're going to add so let me clear the screen so we're going to add and then rebase dash continue escape wq and this now is the last conflict so if i go back to vs code again you can see that we basically are resolving all the commits that we have right because remember we added the h1 and then some paragraphs so here i'm going to take this h1 because this was first and i'm going to paste it there and then i'm going to remove this one here so basically i'm resolving the conflicts manually there we go remove that as well and remove this as well and then indent that and now if i save you can see that this now is the complete picture so this is a heading this was the first paragraph from master and then remember this is another paragraph and this is a paragraph and in fact this has to go up save again and now we have fixed all the conflicts while bringing the current changes from master so if i save this and then in here i'm going to basically say git add and then revise continue and then i'm going to leave this message as is and then press wq and there we go so you can see that successfully rebased and updated which means that now if i say git and then push it says that our current branch is behind but in fact we know that we actually brought the changes from main we fixed all the conflicts so let me show you so in here so it thinks that basically it doesn't know the current change that main add which was the initial paragraph so the paragraph that said um basically this paragraph right here first paragraph so this branch in remote feature xyz doesn't know anything about it right but we know that for fact we actually brought those changes from main we fixed all the conflicts and basically we want to push these changes because we have rebased in this case what we have to do is say git push and then dash and then f for force we can say dash dash force as well so we're going to force push you can see that this time it works and now in here if i refreshed this you can see that it says this is a heading and then first paragraph so basically now we have all the changes from main in our feature xyz branch so this is nice now what i'm going to do is so here i'm going to basically go to pull requests let's compare and pull and check this out you can see that main did have these changes in here which contain this first paragraph but then we brought all of this including the first paragraph right because we've because we rebased and then adding the h1 and then these extra p tags now i'm going to create the pull request and obviously we would leave a comment in here create pull request and there we go so you can see three commits so add some html another p tag and then this was the update so this was the actual uh rebase and we can see the files changed so the same thing and there you have it so i'm actually not going to merge this so i'm going to leave this for you to see exactly these changes but as i said this is probably one of the most confusing parts and once you understand this then the rest as you saw throughout this course is really straightforward as you saw we had to resolve couple of commits in order to rebase properly so usually what people tend to do is when they merge to master so when they merge to master or the main branch if you have let's say three commits right if you have three commits on your on your pull request right so you raise the pull request you've got three commits then once you're ready to merge into the main or master branch what you do is you squash all those commits into one commit and then you merge that into the main or master branch that way we have to resolve only once so usually also if you have like 10 commits it's best for you to squash all of your commits and then perform a rebase and then basically it's much easier instead of fixing all the conflicts one by one per commit you also saw that because we rebased the um branch that we had remote wasn't aware of our rebase so we had to force push because we fixed all of the conflicts right so that's why we had to force push so this is actually one of the most confusing and probably most difficult things that you're going to experience with git everything else it's a piece of cake as you've seen in this course and if you have any questions on rebase do let me know and i'll try to guide you to the right place so that you fully understand this topic so far we've been working with git from our terminal and this is the best way of you working with git but there are times when maybe you kind of want to gain a little bit more information and you don't know exactly all the commands then there are times where you might use a gui client so there are many gui clients out there but the ones that i will mention in this course are github desktop so this is the official one we can see for example here you can see all the changes all the history you can see all the new changes nicely formatted in here so on and so forth even the branches and repositories then we also have sourcetree so sourcetree is one which i have used in the past uh but to be fair i i don't use these clients because i tend to do everything from the terminal and you know as you progress through your career as a software engineer you will thank me later and to be honest most ides they do have git integration built in for example right here i'm inside of vs code and you can see that so i've just opened the folder so learning git folder and in here let me open index.js i'm going to say and and then github just like that and then save and if i make this a little bit bigger there we go and if you notice correctly so in here we have this blue line so if i click on it this is telling me that i have changed here so i have this new change so i've added and and in github and the cool thing here is that this also has reflected this is the git client built in within vs code so here you can see that i do have one change and if i click on it you can see right here is actually showing me the diff so if i zoom out a little bit so there we go you can see the diff so this is the new change and if i cancel out of this and right here we can actually stage so stage changes there we go staged and then here we can commit so i can say added git and then hub and i can say right i want to commit there we go and then here we have all options so we can pull we can push we can stash you haven't seen this we can check out we can clone sony's the fourth but let's go ahead and just push there we go and now if i go back to git hub and then here if i refresh you can see that added and then github so this was from vs code i didn't even use the terminal but as i said you should try and use the command line as much as possible until you master git and then you will realize that you will not use git clients as often inside of github you've seen that i do have these icons right here and this is because i have the jetbrains toolbox plugin and this is why you see these icons right here for webstorm uh intellij and goland so if you don't see this is because you don't have the plugins but it's absolutely fine but what i want to show you here is this button right here so git pod so click on it and gitpod it's really nice so basically gitpod is a coding dev environment for your github gitlab or bitbucket projects which is really nice so let's say that you don't have a fancy machine you can work on your project by launching gitpod and this will open a web browser with vs code in it which is really nice so if i log in with git so it's actually pulling a darker image and if you want to learn about docker i highly suggest you to check my website docker is awesome so just give it a second there and it even has a terminal which is really nice and there we go so you can see that this is actually vs code on the cloud which is super nice really really nice so i can zoom in in here so let me just zoom in like that and there we go so you can basically set up the project but basically you can see all the files that we had in our local machine now they are running within git pod which is really nice and here this is my web browser this is chrome chrome running um vs code i can even open here i could make the changes so you could see that we still get the this line here saying that what was changed so get integration right within which is super nice so if i save this actually you could see the changes here and yeah this is really nice and this is why one of the reasons github is so popular so it has lots of great tools for software development so go ahead and experiment with gitpod let me know what you think about it i think it's really awesome so again if you don't have like a fancy machine um a not not so powerful machine then you can use basically this instead this all for now catch me in the next one as you start building lots of projects on github it's a good idea for you to keep your projects organized so this in fact can be used as your portfolio so in here you see that we've learned about git and we have a couple files and then we have this read.md so basically in here we can have a bunch of information about what this project is about so this is actually um it has its own syntax so this link right here which you can find in the description of this video so you can see here for example you can have lists so you can have lists like that and then ordered lists right here you can have these task lists or check boxes and right here we can have content attachments as well emojis so on and so forth so go ahead and check this page where you can more about the actual syntax for uh working within this md file but basically um what i want to do actually show you that for example if i want to have a picture here i can say for example i can go to um issues so this is one trick i'm going to create a new issue and i'm going to show you exactly what issues are but here i'm just going to drag this picture right here so this is the course thumbnail and then i'm going to grab this link copy that go back actually in here and now i'm going to edit this readme and here i'm going to say that this ripple was used to basically if we want to h2 for example we could say like that so this now becomes an h2 and then here i can paste that and this now will have our image i can also say that this course is from https column forward slash forward slash and then amigoscode.com forward slash courses forward slash git github right so i'm going to give some space there and now i'm going to commit the changes and you can say update readme so on and so forth but basically here i'm gonna commit directly and you can see that it becomes like that you can see we have a link in here and then this is the h2 so this is really nice so in fact this should be um git and git hub and then course so let's make it like that and then commit changes again and right here if i go back now you can see that this now it's much nicer right so here this is the description about this project so i highly recommend you to um you know take your time and craft this page because this is where for example if you apply for jobs this is where most people will end up checking your portfolio right so here you can see as well the list of languages used html javascript go and then people sometimes go and check you know what kind of stuff that you are up to so it's always good practice to have all of this uh organized right so the md file organized or the readme.md file organized so just to show you so as an example i like to highlight so if i go to amigoscore.com so here my courses and then software testing so we have morillo so mourinho has done a great job so i'd like to show him as an example because if you check his github account you can see that basically this is on a user and then this is the course that he took from my website and then he added some description about it and then some tags and check this out so here have a look so it has its index and then about and the architecture diagram and even took his own screenshots which is nice some screenshots again some code example you can also have code examples within your readme so it's this is like this is like really nice right and it also explains the annotations and yeah so if i actually go back and show is portfolio so here you can see that he really took his time and he crafted all of this right so his name what it does where is from some links the linkedin profile twitter so all of this and you can see the list of all projects that he has been uh contributing to and also in here have a look so these are the contributions in the last year so all of this is important when you build your portfolio right so again go ahead and explore uh more and you know take your time to make your page spectacular because i want you to succeed as a software engineer so the profile is actually um customizing here so your profile so i've just went to my avatar and here i can edit my profile right and you can see my one it's not as beautiful as morelo but i'm actually working on it as well so yeah so there you there we go so i just wanted to talk to you about um you know building your own uh portfolio with git because it's really important and making sure that you have your your projects really tidy up to showcase to potential employers let's take some time to explore this page right here in detail and some of the things that you can do with github which i haven't explained before so here you saw that this is the main page right so this is where we have the source code and you saw that we've crafted this readme file so it's looking good and maybe i should actually um have some description here for example so i could actually put the my website link in here so i can just say that and then i can say git for example and then github so these are like some some tags so github there we go and save that and there we go so you can see that this has been updated now in here so let's go through these tabs so here issues so this is how you keep track of all the issues that are present in your project so i can create new issue here and i can say fix for example and then button for example right so this is a title and then i can leave descriptions of what is happening and then i can submit the issue right before i actually do that we can actually assign to someone right so we can have an um someone otherwise will be to yourself we can add labels and projects i'm going to show you projects in a second so here we can also assign this issue with a pull request so you've learned about pull requests so here i'm going to submit the issue and now we have this issue right here and then people can have discussions in here so let me move to pull requests so you've seen pull requests so here we have one pull request actions so this is really interesting this is mainly for continuous integration and deployment so ci and cd go ahead and check my website i also have a course on this coming out very soon but yeah but we're not going to touch too much on this but this is really nice um that github offers so give them actions so i actually think that it's amazing what they've done here then we have projects so project so here let's go ahead and create a project so here for example uh you can say um team i actually have a team team amigos for example and then here we can pick a project so basically kang ban so this is um the style of your of your board so let me just say basic i'm kanban and then we can have a description or i'm just gonna say next and then from here check this out so here now we can have basically a list of cards or tickets and then as we complete these we can move them around right so let's say that um in here for example um basically you saw that here have a look we have the fix button so what i'm going to do actually it say that this is part of um this project so team amigos there we go and now if i refresh hopefully should be somewhere here and it's not um but basically we can move it right here so right so fix button and you can see that now it's right here uh and also we can have the feature basically you can just move stuff to to do and then maybe someone has picked up this then they can move and then once it's done you can move it to done and basically this is so nice for you to you know track the progress of your project and do a little bit of project management as well right and then we have wiki so this is mainly for documentation and then we have security so this is um stuff to do with security about your project you can have code scanning depend about alerts security advisories so if there is a vulnerability in your code base then basically all of this you can set up in order to let you know what is wrong with your code then we have insights so you can see basically who did what who who created the pull request you can see contributors and a bunch of cool information then we have settings so settings so this is where you actually customize a bunch of things but one thing i want to do is in manage access if i put my password and then here i could actually invite you as a collaborator on this project so this is how you add people right so here you add by the username or full name or email so this is nice and then basically here um basically we've got branches so i can actually rename here so remember we can go back to the master to be as the default branch but for now we we don't want that and we have web books we can configure web books notifications actions environments we can all we can store secrets as well so this is really nice uh one thing which i want to show you is so in here so options so if i scroll down you see that we have the merge button so here this is uh when we can just say right so we just want to allow squash merging remember we talked about squashing commits or allow merge commits right so let me just remove this so this is much better and you can see allow auto merge also get the pages you can delete your project right here and yeah and then basically you can start so if you um would like to give me a star on this project i would appreciate we could see now i have one star and then forking so this is when you want to basically take this project into your own account and then basically work independently from me right so you've copied my project but then you have control of what you do with it and um yeah and then we have pull requests you've seen here issues as well marketplace so the marketplace right here this is where you this is where you can see all the apps and actions available so go and explore and yeah that's pretty much about it next let me go ahead and show you exactly how you can get involved with open source software right in here go ahead and click on explore and i want you to see this so here you can see that these are repositories all around github so there are thousands of these if not millions of these repositories that you can explore so here if i click on topics i can check the ones by topic we can see for example the ones on java so repositories on java and you can see that have a look so 122 000 stars so this is quite interesting right so these are the trendy ones so if i click on it so i think this actually um allows you to learn java but in chinese maybe but it's quite popular so in here we have lots of these and if i click on trending you can see what is trending right now so the cool thing here is with github there are thousands and thousands and thousands of these these repositories that we can contribute so in here if i zoom in you can see that built by and then a couple of people in here so let's actually have a look at for example just pick any python cheat sheet right here and you can see that they have a readme so we've learned about readme and you can see that 10 people have contributed to this project right here so you can go if i scroll down so here you can go and you know find any any project in any language that you are interested in and then you can work on it right so they have guides on how you can contribute to a project so if i click on this one called trader so here you can see that they have a nice readme with this awesome giphy and right here so remember issues so these are the current issues so some people have reported these issues and now they and now they have to go and fix these issues right so what you would do for example you'd go to a project find the open issues and then just pick any that you want and then start fixing those issues basically and that's how you contribute to open source so let me actually show you one which is really famous so here i'm going to see if i can search here kubernetes so this one here so kubernetes and check this out so this one here have a look how many contributors 3 000 people contributing to this which is which is amazing right so this is the power of open source a bunch of people from all around the world get together and they build software right so here you can see the readme and if i scroll down you can see that you cannot you can actually support as well and then this is some information about how you can contribute so here they say how to contribute code and documentation auto contact etc so this link right here so there you have it right so if you have an interesting project so let's say that you create a repository within that repository if it attracts a lot of people then you can be the owner of that repository and then who knows you build the next awesome um facebook maybe you wouldn't open source facebook but uh you know a piece of software that it's useful for um you know other developers to consume right for example kubernetes which is really really powerful basically uh yeah so this is all actually let me give them a star because i think what they're doing is amazing so and also let me watch this um actually i'm not gonna watch for now uh yeah so there you have it oh have a look almost a thousand pull requests look at the issues almost 2 000 which is insane and we can even see the projects so we can see workloads so you've seen this right so this and this one looks a little bit more polished so you can see freezer backlog in progress done and this is how they are keep tracking of what's been done in the project so this is super nice so there you have it this is pretty much a quick overview of how you can get into open source software and also one thing that i want to mention is if i go back in here you should really be checking the license so all of these projects they have a license so here and this license dictates what you can and cannot do for example here you can see the permissions for commercial use modification distribution pattern use and private use the limitations are warranty liability and trademark use right so you also need to have one of those in your project if you want to be clear of what people can and cannot do so there you have it this is a quick overview on how to contribute to open source and basically just go out there and explore the list of available projects that you think that you might be interested in and yeah there are loads of projects available that's all for now catch me on the next one right i want to thank you so much for sticking around and learning git and github with me i would love to know how you found this course and if there is anything that you're still not sure or understand please do let me know but what we've covered in this course is pretty much the essentials that you're going to be using throughout every single day right so it has way a lot more commands but in reality you're not going to use all of those commands every single day so what we've covered in this course is the essentials to get you going every single day i'm going to leave some links where you can go and explore about other commands and also all of the commands that we've covered in this course i'm going to leave the links down below so that you can reference and if you want to go back then you have exactly what each command does so you have a description of what each command does it was a pleasure teaching you um also actually almost forgot so if you haven't enrolled to the um terminal bash and veeam essentials course go ahead and enroll literally go ahead and enroll because as a software engineer you must know and be really comfortable when it comes to using the terminal so go ahead and roll to that course this is all for now and i'll catch you on the next one you
Info
Channel: Amigoscode
Views: 92,089
Rating: 4.9579897 out of 5
Keywords: amigoscode, github, github tutorial, git tutorial, git rebase, git and github tutorial, git advanced tutorial, git and github tutorial for beginners, git bash, git branch tutorial, git bash windows, git clone, git commit, git commands, git crash course, git and github basics, git and github beginner tutorial, git and github course, git and github complete tutorial, git and github commands, git and github explained, everything about git and github
Id: 3fUbBnN_H2c
Channel Id: undefined
Length: 141min 42sec (8502 seconds)
Published: Sun Feb 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.