Complete Git & GitHub Tutorial 2022 ✅ | For Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everyone i am rishabh and in this video it is a complete tutorial about the complete git and github you will be learning about what is get what is github how we work what are the basic concepts of using git and github the whole complete tutorial you will be learning from this session i will be using github cli now what is getup cli cli is the command line interface there are two ways you can use like in if you are using any code editor then through that also you can access the github means git and github you can work and also there is a way which is most preferable is github cli command line interface like working in the terminal you can see right so we are going to do in the command line interface because that's the most essential and important thing to learn i will be telling you about the complete thing how the things work what are the basic concepts and all the things so you will be clear after seeing this video the whole thing so there the video will be divided into five parts the first part is what is getting github second part will be what is the difference between guitar and github that mostly people get confused right that what is git what is github they confuse between them the third part will be installing git and github the fourth part uh sorry by mistake the third part will be installing git and creating an account in github the fourth one will be starting with get means we are going to do get okay and after that the fifth one is working with github right so these are the five different parts of working this tutorial so i think that you will be mostly clear after seeing my video that what is get what is github how to work with them right so don't just see this video by slipping down or sitting down come with me open your pc or laptop wherever you work open the thing create your setup and start working with me or else you won't understand the thing see this video you won't understand anything out of this video okay so sit down open your pc and let's just begin and one more thing like this video share it with your friends those who don't know get on github and subscribe my channel what you're waiting for and click the bell notification so that you can get the latest notification of the videos whenever i post them right so let's just begin without wasting any time so the first thing that i would be telling you about is what is good and what is getup okay so uh let us try to understand in simple words what is get get is a version controlling system or you can say is a version controlling software okay now what is version controlling let me say that you are making a folder today and you are you do this thing especially in while they were working right you are creating folders you are adding files to them you are making changes to them and daily basis you are doing these things right and also when you are creating your projects you are doing these things or also while you are coding you are also making changes in your quotes right now say on 10th of december you created something a folder or say you can say some files you added on 11th of december you made some changes in this files or folders okay and on 20th you realize that you have made some mistake on 11th so you want to come back to the 10th stage so if you are working normally in your project so you can't do that or you can see using it you can come back to that stage okay so that is version controlling like the versions that you create every day after committing files after committing and get all the things are saved okay so that get those for us and that's the software get now what is comments and all this thing you might don't know at this point of time don't worry i will be telling you at the further go of this session so now the thing that comes out here is uh what is uh github like you say you are making some changes or you can say you are working on a project okay and now you want that your friend from other state or say from other place or say from his home he also want to make the project along with you as a team member or you can say as your friends or you want to contribute both of them to a single project then how you can do that thing you can't do that if something is on your local machine and you are working your friend can't contribute to your local machine because you don't have the access of that one so there comes the thing github github is a platform where you host your files or let's say you can say your folders anything you can host there and the hosting is known as a repository so github gives a repository where you can host your files and details and you can create different repositories so that's the github like what you're doing in a local machine through get all the changes that you can see or you can come back to version all the things that you can do in a local machine that is simply hosted to some place where other people also can come and can contribute so that's github so how both the things work is get and github both of you can contribute to a same place right so like say you are making some changes and keeping that thing in the github now today your friends also wants to contribute to that project he will take that from github he can also contribute and then put it in the github so that both of you can work together and that is the power of get plus github so now i think that git and github is basically clear to you all guys how we work right so there is also git lab you can also host there also providing the same features as github but git is the main thing which you have to use for a local machine okay so mark my words the difference between getting it upgrade is basically version controlling in you inside your local machine github is the place where you host all the changes and all the things that are done in your local machine so that other people can also come and can contribute so that's the difference between git and github so now i think that it is almost clear to you all guys that what is the difference between git and github right so if the thing is clear so write in the comment box that yes git and github is now clear the difference many of you uh get confused in this part only the difference between git and github many of you don't understand this thing only so that is the difference between git and github right so the next thing is uh creating means installing git and creating an account in github right well because doing that thing you can't move ahead right so the next thing that comes out here is installing git and creating an account in github so first thing open any of your browser okay so simply i have opened a browser here now simply search here get download get download you will search and the first link that will come here is the official website this one simply click on download git and once you click on this one this interface will come website for downloading git okay now from here you can see your uh operating system which you are using mac windows linux you can download that so for my case windows i am not showing in this video installing github because i have already shown in an older video how to install github okay get sorry not github how to install git so see that video click on this and it will download and uh perform the things so once you are done with this thing uh you have to create an account in github also so that you can as i said open source contribution right so for that uh come in github.com now in my case i have logged in already by creating a pro by creating a profile so my case it is showing like this thing but in your case the default one will come let me show you if i open it again to tab and say github.com so you will see like this it will come and after this sign up for github click on this one now the thing will come where you can create an account while signing up so give your email address then it will ask for password and some other details give that and your account will be created and once it is created simply it will come like this also you can visit your profile like by clicking on your profile it will open your profile so this is my profile actually it looks cool right so how i made this designing part i have made a video if you want i will give it the i button you can go and check it out so that's the basic thing of installing it and creating a github account now the next part we are going to start out here is working and understanding complete get okay so now once you have installed the whole thing the git and github after opening the profile in github also now your work is to do like this open any of the folders or create any of the folders now this is my file manager or you can say file explorer in windows now here i have created a simple folder git and github okay you can create that one or anything and inside that i will perform my things that i will be showing you okay so you can also create like me or you can create anything else now what is this thing here this thing is get the bash now what is git best good bash is command line interface for working and in this git batch you can perform linux commands okay which is essential for us working in windows terminal we can't do like linux commands so for that i am using git bash how to open this one after you install the github you can like uh come into any of the folders like right clicking on it if you are on windows 11 then click on show more options uh by like if i want to open this git github folder in my git bash right click on this one and click on show more options and here you can see get the bash here and get gui or don't do git gui because graphical user interface is not much preferable uh the command line is preferable so get bash here click on this one and this thing will be open okay so also here you can see the folder look or the file location that is in git and github folder right so the whole thing is now clear i think that how i have opened this two things side by side so that i can make you understand so let me show you first uh some linux commands so that it will be easy for you to understand so that it will be easy for you to understand right so the first linux command is ls now what is ls ls means list of all the things that are inside a folder now you can see the folder is empty so nothing is coming right so that is ls for listing all the things uh now it is showing nothing but i will show you now if i want to create a folder like say here so in windows what we did click on new and we click on new folder but using this linux command you can also make folders that is mkdir make directory mkdir make directory okay so that is the command for you can say making a directory or say a folder okay so in linux mkdir and then you have to give the folder name that you want to create so like i am creating tutorial tutorial and after you hit enter now you can see there is nothing present here and once you hit here you will see a folder has been created currently here so that is the linux commands how you can create folder now if you want to go inside this folder now if you want to go inside this folder what you have to do that also i will show you or you can go inside this directory okay now as i was showing you that ls command to show the list of all the things that are present now presently i am in the git and github folder which contains tutorial so if i do ls it will show me tutorial so if i hit enter you will see tutorial is coming that i created the folder right if you create other things like files that will also be reflecting here right now as i told you that i want to go inside this tutorial folders and i will work inside that so the linux command for that is cd what is cd cd means change directory my present directory is getting github now i want to go inside this gate and github and inside this tutorial folder so i will do the change directory so it will take me inside this tutorial and i will give the folder or the directory name so i'm giving it tutorial so once you hit enter you will see that at this place after git and github now tutorial is added so what this thing means you are inside this tutorials folder if i hit ls you will see empty there is nothing right so that is the linux command for getting inside and now if you want to come back to this git and github again means your work is done in tutorial so you want to come back so for that what you have to do cd and one minus so this means you will come back to the previous stage or you can say one out so if i hit enter you will see that this will come get and get up if you do cd minus again then it will take you to personal okay so that is how we like especially go inside and come out of a folder or directory or anything okay so i am doing removing all this thing right so now i want to work inside this tutorial folder so whatever work is to do type your cd tutorial right and you will come inside this tutorial so i'm opening this folder here so now we are in the tutorial spot right so now uh as i told you that if you make some changes or you you can do all these things and blah blah stops that i all told you as i told you that the history will be maintained in get and github right get right so let us just see that how it is done so let us say that if i make a folder at or you can say if i make a file so first thing if i do ls you will see nothing so now let us say that i want to create a file inside it right so to create a file the command is touch by writing touch you can create a file here okay or you can say anything like files okay so i am giving app dot java so i'm creating a java file that is app.java if i hit enter you will see at this side app.java is coming presently right so that is the touch command is basically used for creating a file okay now i want to remove this file say right so for that there is a command rm then a dash rf and then you have to give the file name say app.java and once sorry app.java and once you do that you will see it is gone from here so that is the basic command how you can delete a file okay using cli so i'm clearing it right now now whatever we did there is no history maintained right like say you created a file and you are changing now you want back that file so you can't do that right so for that we are going to use github now after you are doing all the things you have to like git is a software right as i told you now to present all these things to create changes and history on this tutorials folder you have to initialize it like you will say hey get come here and track all the files and the changes that i am making right so for that to call git you have to initialize git okay now for that there is a command to call get to initialize it there is a command get in it get in it right so that is the command get in it now once you do this thing git will be initialized in the tutorials already you will see in which folder or in the which directory we are currently and in that only the git will be initialized so once you hit enter you will see initialized mt git repository in this directory and dot get folder is being added inside here but if i do ls you will see nothing right nothing is here so how where is it initialized so and also you can see a master tag is coming here now what is this master that also i will be explaining to you in the further session now what is uh as i was telling you that initializing get we can't see it now this dot folders are actually hidden in our uh windows to to see that thing uh you you can come here and do show hidden items and you will see dot get is here right and also if you want to see it through command line you can do ls and simply type a after that and if you hit enter you will see that yes dot gate is there right so it has been initialized in our local directory so i am removing this currently or hidden items i don't want to see that right so now it is being initialized now whatever we are going to do it will track all the things okay it will simply track all the things now i have added get in the folders now i will see that how we can maintain the history how we can do all the stuffs so if i show you in my chrome that in my repositories that i have been working on so if i show you one thing that is this one now in this you can see the histories total 70 commits are there so now this is the history that are maintained especially in github same thing is done through get only but this is hosted as i told you right so all this history that i am doing so that is maintained right so how we can maintain it on our local machine in through git i will be showing that thing so let us come back where we were previously right so now in this master say i am first creating a new folder means not a new folder so i am creating a new file right so i will say touch app.java so you will see app.java has been created now if i want to save the thing right so now uh let us say that by understanding a simple thing that hey get come out make a to-do list where i will be keeping this app.java saved in today's date at this point of time so for doing that thing to creating a to-do list what i what we have to do here is say we have to do get ad like you can see this ad as a like adding in a to-do list okay so where it will add the thing now there are two things that you can add after this add git add command that is first one is dot now what this dot represents it will perform all the things that are present inside this folder tutorial not only app.java if other things are also added it will do that thing okay and if you also mention the file name which you want like say i there are other things also if i say present here you only want app.java so you can do that so let me show you that thing so if i do touch um main dot java file i am creating two files app.java main.java now you want to initialize or you can say you want to create a to-do list where you want to add only this after java at this point of time you don't want main.java so for that adding it in the to-do list you will have to do get add git add and you have to give the file name that is app.java and if you hit enter you will see it is added now how to see that one you will simply type get status once you hit status it means you it will show that what is the present to-do list here so if i hit enter you will see a new file app.java is there and untracked file means not added in the to-do list that is main.java main.java is not added means it is untracked still now means it is not dragged by github because you are not adding it in the to-do list the things you will add in the doodle is that will be tracked by github by git sorry i am mistaking the thing by git right so you can see new file app.java it is in green color right so now as i told you that if i want both the things to be added in the to-do list or say all the things that are present inside the tutorials folder so if i want to add all the things so let me clear first now so to do that what i can do here is get add and simple dot i don't have to give any folder name or any files name all the things that are present in the tutorials all the things will be added so if i hit enter now if i do get status sorry if i do get status you will see on branch master two files are being added app.java main.java right so hey git create a to-do list where both things are being added right now now you have to make a commit so that these things are going to be saved so what is commit as i told you commits are like say you are doing adding in the to-do list and now save the to-do list at this point of time right so is it clear like uh both the things are done creating the two things adding these two things in the to-do list i want to add these two things and now create a timestamp of today's date today's time at this point of time i want to make a commit here where commitments i want to save these things in git right using git so to do that you have to give the command get commit and then m now what this m means this means a message that you want to keep for this to-do list for saving so you will say that added to or you can say edit app dot java and you can say main dot java files okay so that will be the message that will be saved here so if you are like as i showed you that uh there are different commits here right you can see added onboarding animation added boarding animation added yearly budget and all these things are there so these stuffs are known as commits so basically this stuffs are known as comets as i told you now that is a message that i want to keep added app.java main.java files and hit enter once you hit enter you will see master no commits added app.java and this okay and if you now want to see that get status like i am first clearing these things now if you want to see the status that i was showing you in the to-do list that was there stitus status you will see nothing to commit working on a clean tree that means that the tool is that we were like you can say that whiteboard where we are adding the two things we are adding two things the folders or you can say all the things that we want to add in the to-do list so that this to-do list will be after saved as a commit with a message so that you can come and see what are the things that are done at this point of time and the time stamp right so that is basically done now the whiteboard where the first to do was done all things are now clear because the thing has been saved already in the comments so this thing is now clear so it is showing that working on a clean tree nothing is there right now if you make any changes here that thing will become in the git status and now how to see the commits that we were seeing like the message you as i showed you in github that we were seeing that using these messages how to see that in our git right so that might be a question for you also so how to see that thing so let us just see so to see that thing what you have to do is get log git log will perform or show you all the commits that are provided by you if you hit enter you will see commit with this hash id add head now all these head and master things are not known to you don't worry i will tell you and you can see added ab dot java and main.java files at sunday february 13 all the stuffs okay so that's the point here the thing is being saved right so first we made a to-do list right so first we made a to-do list and the things are being committed so that is how the changes are being saved so i am making it clear now right now i want to make some changes or you can say that i want to make some changes inside this app.java file so that i can track it so i will make some bunch of changes say in the app.java so i will write here vi app.java now what is vi vi command is to open this app.java here means in the command line interface itself so if i do that you will see app.java is being opened right and now uh here i want to write some lines of code say i will give a class insert first yes class i will write app and inside that i will write okay so that are the things now i say that i have made a a class app and made some changes inside that folder inside that files app.java okay now i want to save this thing so for that press escape then colon x so now if you open this app.java say in vs code let me show you that in vs code if i open if i open you can see this thing that i have written so that are the things that you can do through uh command line by writing vi and that file them okay so i have made some changes here now if i do get status you will see that it will come in the to-do list or you can say that it will show you that head issue that you have made some changes what to do about that thing so if i do get status and hit enter you will see that modified app.java right so you will see that i have modified app.java and git is now showing me that thing previously it was showing that clean trade in the total list now it is showing that hey you have made some changes do you want to add this thing or you don't want so it is showing in red that the thing is untracked currently okay modified has been made here so now i want to add these changes so for that what i have to do is same thing get add and i want whole things so i will simply give dot now all the things will be done and now if i do get status you will see sorry sorry so if i do get status so what you will see modifier this thing is being added in the to-do list so get it was telling me that hey you have made modified some changes that was in the comment previously now do you want to add it in the to-do list or not so i said that yes get add that in your to-do list so git has added it and you can see it is coming in green color in the get status now in the comments previous comment there was only one thing that was committed now if you want to check means if you want to add these things like say you have made some new features and now you want to commit it so what you will do is you will do get commit the same thing again the message you will write you will say added new codes added new codes so that's the message and once you hit enter you will see that master added new codes okay one file changed four interactions right four lines were done so four interactions right and the file means one file only was changed main.java was not changed so all these things are showing to me uh by comparing it to the previous version or you can say previous commit now if i do get log you will see two commits are there right say this thing and this thing right two comments are there you can see the timestamp and all the things so these are commits and all these things right so now i think that uh it is now a bit clear to you all guys that how you do commits how you track it how you do changes and how you do commit again and now if you do get status get status you will see clean tree okay so in the doodle list i have committed so it is coming clean tree type as i explained you now the next thing comes is that if i make some changes here in the main.java and if i add it in the to-do list how to remove that from to-do list right like if i say i want to delete this main.java file so for that rm rf okay main dot java i want to delete this main.java file from here i will hit enter you will see main.java is now removed okay so now this is also history maintained by git so now if i do get status you will see it will say that you are deleted this main.java what to do about that should i add that in the to-do list or should i not add in the to-do list so if i do get status you will see deleted main.java so it is showing us that you have deleted main.java file so what to do it is asking us right so now let us say that i want to add it in the comments means i want to add it in the to-do list so for that i will say git add and a dot so all the things are now added so i will first clear now i will do get get status so you will see that in the to-do list the thing deleted main.java is being added so what i did deleted that one so it was asking so should i add it in the to-do list you said yes added in the to-do list so it was added let's just say now that you don't want to add this deleted main.java one so for that how you can do that one how can you do means come back or you can say remove this main.java from this to-do list right so to do that there is a thing known as git restore okay so i will simply write here get and i will write here restore staged okay so stage means that was added in the to-do list we deleted main.java and i don't want that so i will write main dot java so i want to restore it back i don't want in the to-do list this thing i will hit enter now you will see that thing is performed so if i do get status now you will see that this thing is currently in red which was in green presently so this means you have added in the to-do list but now you don't want that thing in the to-do list means i don't want to take it so i will simply remove this one okay so that is how you can remove or you can see you can restore from the stage or you can say from the to-do list right so that is a basic command get restore okay so now let us say one thing that if i now do get log so let me first clear the thing so i will do a clear now let us say that now i have as i was telling you about history and all the things that are maintained using git so now let me say that you have created the app.java you are also there was a file which was main.java right which was in our comments but now this was deleted from here let us just say that that was a precious file and you don't want it to delete it but it got deleted so now you want to get back that thing so how you can do that thing so simply if you do get uh first thing get log you will see that there are two histories right where the two files were created so now you want to come back where these things were done so first let us do one thing let us first clear this thing so now let us say that first i will commit the present thing that was there so i will do git and then i will do add then dot all the things added i will do a get commit and then with a message that deleted deleted main dot java java right so i have deleted main.java and that is our commit right and now as i was telling you that you want to get back that thing so if you do get log now you will see three comments are there the first commit was the initial commit that we did right added this thing then in the main.java we added this code and now i deleted main.java now if you want to get back the main.java how you can do that thing how it is possible that i was telling you can get back that thing so that is the very important thing how you can get back so for that the main thing that is there is reset means we can come back to this commit where we added some new codes and there was main.java present right or you can come back to this one also where we don't edit this codes and the added the simple files there right so whatever you want you can do this thing like you can come back to any of the comments and now how to come back like say if you want to come back means if you don't want this thing the thing that you committed here you don't want to do this commit you have to give this hash and you will have to do reset so simply do copy here ctrl c you have copied so this one was the part where i added new codes so i don't want this commit i don't want this particular commit right so i want to come back to this commit so if you can say that get get first let me clear this thing clear yes now if you want to come back to that commit which you don't want that was deleting the files and now i will simply write get reset and i have to paste the hash so for that right click here and simply click on paste so this is my hash and if i hit enter right now you will see on stage changes after reset now if i do get log you will see sorry get log you will see there are only two comments present right so that is how git is working actually now i am clearing this thing so this is done now i will uh now i will show you what is uh stash okay uh so resetting a commit is also done and now the next thing comes is dash now what is dash say let me create a folder say i will create a folder touch and say new dot java okay a new java file has been created then i want to add touch one dot java okay so two files are being created new.java app.java one.java sorry it will be a dot so don't worry i am not making any changes currently here so now if i do get status get get status you will see so now if i do get status presently you will see that uh the deleted main.java this thing is coming because i have reset it right i have reset it in the previous stage now app.javanew.java all the things are coming right so the two files are coming i have added right so now let me say that i want to add this all the things in the to-do list so what i will do is uh get add dot now if i do get status if i do get status you will see rename this thing to under java so don't worry so i have made some changes here and new files new.java so i have made some changes here right and added them in the to-do list right so now what i want is hey get keep this to-do list aside i want some other things also to do here and i want to skip this thing i don't want to lose this thing but i currently don't need this thing actually i am creating a second to-do list like to keep this to-do list aside in a safer place but i don't need this currently so i have a command so first let me clear all these things so for that i have a command that is get stash right get stash and then simply hit enter you will see saved working directory and index now if you do get status you will see nothing in a clean tree so that means the tool list that we created that is all the things that we did that is app.java here two other files were also there now you can see that all the two things are not here i have come back in the previous stage like i have to keep that thing aside i don't want that currently but keep it safe like say you are creating a new feature for an app or you can set a website now you made some changes but you don't want that thing currently so you want to keep that thing safe but you want other things that was working you want that thing and you want to work on that so that is what gets dash comes so as i told you that i deleted main.java that is also present here and the two files that were added that are also not present here right so that is known as get stash now that thing is safe at other side now if you want to get back that thing like i deleted this main.java and two things were added so now the new feature add the new feature means add the other two files and delete this main.java so for that there is a command get pop sorry get stash and then a pop get stash pop means hey think that was aside bring that down if i hit enter you will see main.java has gone and these two files are being added again all the things are came here right now so that is good pop and stash bringing back to the things all the things that were changed so now if you do get commit or you can say you can also do get status you will see the this is the current status two files added deleted this thing so i will do a get add and a dot and if i do get status you will see all the things are done now if i want to commit all at a time so i will simply do commit and a message that new files added done done right so uh if i do get log right now you will see there are three commits first one added new quotes and new files added means these files are added so that is how we work with it so what do you learn from here initializing get working on get adding commits adding in the tool list right and all the things are being done stash reset removing from commit coming back in the other commit that you did previously all the things are done right now right so i think that it is almost clear working in kit now let us try to understand the very important part that is this master why this master is coming here or if you do ls let me show you ls slash a you will see that dot git is there right and if you do cd dot get and if you like to ls inside this one you will see something is there head description index hooks objects now these are the inside this uh if i show you from here also show hidden files then inside this git folder all the things are there right here then all these things right so coming back here i don't want uh to show hidden files currently so now all these things are there right head and all these things now what is the hit hit is the now we are going to understanding the branching thing what is branching and all these things so now head is the basic starting point where we started so to understand the branching thing there is a very good platform i will show you this one so you can come in this url learning git branching.js.org what is a branch especially let us try to understand branch let's say that he a tree and tree has two branches then from these two branches other branches are also there right so that is basically branching and it is same for github means for git also right we can create the same thing using get we can create different branches we can work on that branches but the different thing is that we can merge that branches in tree we can't merge that branches like in real tree we can't merge means you can't see that two branches got merged at a place but branches are there right so but in gate we can merge that branches also so let us see that thing so say this is our main head that was c0 right that was c 0 was the main hit that was present you can see head right currently head but now if c1 is there you will see this is the present head means currently we are working here like say you have made some commits right so it is right c1 okay so now this c0 was our head presently and we are working in the main branch and the master and main both the same previously it was main but now in the gate it has been changed to master so don't worry this main is the master itself that was being showing at all the time so now say you are giving a commit here you will see this has increased so this was the present head before coming to this and this is the head right now now let us do other commits we did three commits right so let us say that it was previously like this and you are here right now right and now you want to create a separate branch right so to create a separate branch like you want from c3 two branches to be there one is main and other one branch you also want so for that there is a thing that is known as command get branch and after that you have to give the branch name so i will give it test okay and if you hit enter you will see a test branch is also created but now nothing is being showing both are at the same place c3 because at this point of time both the branches are at the same point means no one is ahead or you can say no one is being separated both are having the same lines of code or you can say same files and all these things so both are at the same place now you can see there is a star at this point so that is main and there is also test so both uh both there is no star there is only a star at the main so that means we are currently in the main branch now if you say that i want to change my branch to test right means i want to work in the test branch currently so for that there is a command git check out git checkout and then you have to give the branch name so i will give here test and i will hit enter so you will see that star is presently at the test means we are in the test branch now you can say that now in the test branch you made some changes and you want to commit so now whatever commit you will make that will come in the test branch because your head is present in the test so if i say that get commit you will see test branches ahead and bring branch is behind that one test is one ahead let us say that you made other commits so i will give get commit you will see one more commit means i am making changes in the test branch not in the main branch if you want you can come back to this main branch also so if i do check out in the main branch get check out main and if i hit enter now you will see star is at the main branch now you want to make some changes in the main branch so you do some changes and you do some comments so you will see that now branch is being created you have made some changes in the test here two commits and now in the main branch also from this point you are making other changes here so you will see this one let us make some other commits also right so you will see this branch is ahead and this but both are different now what you want is to merge this test to this main you made some feature like say you are creating an app you are at this point now you created a separate branch to create a separate feature you made this feature and you are also working in this one but you now you want these features to be added in the main branch so for that you will write a command get merge get merge and once you hit enter sorry you have to write get merge and then you have to graph the branch name that you want to merge so for my case it is test so i will give test means the present branch which i am is main i want to merge test in this main branch so i have given that one and now if you come and hit enter you will see test is being merged here and now we are presently at this point of time right so that is the thing i was saying that is branching merging and all these things now there are different things like conflicts and all these things will come i will also show you that thing so this is the visualization how it looks actually but now we are going to do it in the command line interface using cli right so we were here currently so i am making clear i want to clear all those things now i will show you the difference in branching okay so presently uh let me come out i am in the git dot git directory so i will come out of this one now in the i am in the tutorial you can see master here right master we are in the master branch so let's first create a branch so to create a branch i will do same thing i will write get branch and then i will give the branch name test okay so i have created a branch test but test is not visible to us so let's just check out to the test branch so to do that i will do git checkout test i hit enter and you will see switch to branch test and instead of master which was previously master you will see now we are at the test so it is showing us test the present branch we are it will be showing that only right now in this test i want to modify some things like let us say i don't want this new.java and one.java but in the master branch which was there all these things were present so now i want to delete this thing so i will write rm rf new dot java new dot java and one comma java i want to delete both the things so you can see both the things are related in the test right so that is basically performing in the test branch right but now if i switch to master branch you will see both the things were really present so let me first uh commit these things right so what i made changes in the test let me commit first so i will write get add dot then i will do get commit classroom and with a message delete it the new files so now the commit has been done so if i do get status you will see nothing play entry and if i do get log you will see deleted the new files but this was at the head in the test not in the master branch okay so let me clear this thing now okay it has been cleared now what i want to do here is i am willing to come back to this master i have made a commit here i want to come back to the master so i will do get master get check out master and once you hit enter you will see a magic appearing here that is the files that we deleted that will come back so if i hit enter it will switch to master and it will be having all the files that were in the master because we are having two branch it is now git is now saving both the things we are deleting from this branch but this branch is having the things that is the master branch right so if you are switching from this to this it will having all the things right so that was i i was telling you we are switching to master so that is how we change this thing and now say let us say that we want to merge both the master and the this thing so i am in the master branch currently now i i want to delete this one comma java in the master branch so i will do a thing that is rm rf one rm rf one comma java so this will be deleted from the master branch right now i want to merge both of the things that are in the test and all the things so first i will uh do a commit here so first i will do get add dot and same thing again get commit m say removed removed uh one comma java okay so git commit is being done so now if i say that i want to merge the test branch with this master so i will write here get merge and i will say test so you will see updating and it you will see that it has been deleted the other folder file that was present new.java so that is how we are merging branches and all now one more thing that you will see is a conflict that will come when we will be working in some projects and all these things so let me show you the conflicts parts now let us say that i want to open this one app.java which is in the master branch so you will see this is there and now let me make a change here so if i like add something so this is you can see here is a green coming and that i was telling you that github uh in the code editors that is the gui right so this is not our part what i was telling you is i made some changes in the app.java and now i am saving it by control s okay i am saving it by control s but now uh let me do one thing let me open at this side only okay now you can see it is in the master and we change in the master branch and now let us put in commit this thing so i will simply do get add dot and i will simply and i will simply do get commit with a message added new lines added new lines right so i have committed this thing right now if i change my branch from master say i will now do get checkout to test check out test so here is my vs code my code is opened right this point now you can see that green line has gone means this one is added in our comments so now if i check out to test branch what you will see here is this line is gone so why it's happening because we changed in master branch but not in the test brush we change in this branch but not in this branch right so now i will make a same change we are in the currently in the test right now and now i will change in same line right and i will make here hello world or i will change this to get conflict conflicts right to show you get conflicts i am doing these things and i will save this one right now now this thing is being changed presently and now let me do this thing means i am what i am saying is i am making changes in the same line right so that is git conflict now if you like say which i wanted to explain you say you are making some changes in line number three in the folder or in the file and your friend is also working remotely from his home and he is also changing the same thing and both of you are wanting to merge it right so what will happen is it will be confused like hey both of you are doing the same thing how i can understand what you want to do help me right so if i now commit this thing i will add get add and after that i will do a commit git i will do get commit with a message i will give a message that added same line to do a conflict okay so don't go in the spellings i'm writing a bit faster so yes it is being now committed and now if you come here the this will go from here as this is being committed now if i uh say that i want to go in the master branch get check out master you will see let me show you this side you will see instead of get conflicts it will come hello world you can see it is coming hello world right and now if i want to merge the things like i the things that are made in test i want to merge that in app.java means our master branch so i will simply write git merge test and once you do this one you will see it will provide us conflicts because we have made changes in the same line and you can see conflict has been coming right hello world and good conflicts so good is now a bit confused what to keep and what not to keep so you can resolve this conflicts by helping it like if you want both you can keep both of them right if you want both you can keep both of them and if you save it now get you can see auto merging this one conflicts has been came so now if you see get add dot so you have resolved the conflicts and now you are push you can say get status you can see modified this one conflict solving came but you are still merging you can see all conflicts fixed but you are still merging right so that is the thing i wanted to tell you right so i will do get commit and then i will give a message like you will say added test or you can say merged merged right and merged it will be merged right so if you see now get status you will see this is gone working on a clean tree which was presently merging master merging you can see it is a master right so that is how we make changes in our github how merging works and all those things work okay so if you do get check out here in the test branch you check out test you will see here is only one line so you can also merge master to this test also so you can say get merge master you will see both the lines are now coming in the test branch also you can now add it in the to-do list and then finally commit it you can give a message merged master okay so working on a clean tree now both of things are gone right so that's how we work in git i think that get is totally clear to you after seeing this video and these are the basic things that we do in our get while working in projects or something like that so i'm closing this one right now and now the thing comes for github right so i think that you have created a account in your github right if you have not created just go and create your account first so that we can work now let me first uh check out to master branch master right now we are in the master one now say i want this whole thing to be hosted in a github so that my friends can also contribute like as i am doing my friends can also contribute and i can also get what they are doing so for that github is required now for that thing come here and open your github as i was saying you now come into your profile you can come in your profile and you can create a repository okay click on this plus and click a new repository where you want to store all the files that you are presently working so repository means you can say a separate hosting for all your files with a name so repository name i am giving this tutorial as i made the folder name giving the same thing you can also give other thing tutorial okay and now i'm making it private i don't want it to make public i'm going to show you all guys right and click on create repository so it will create the whole thing right now how this code will come means what i did here how it will come to this github how will it come right how will it come so to do that thing there are also few commands right there are also few commands so let me show you that thing so first clear now you want actually what you are wanting is remote access that is means you are hosting that place but remotely means from your local machine you are doing wanting to do that thing so that is known as you are wanting to work remotely so to do remotely uh there are commands so first thing is uh you can come here in the chrome you can come here in the chrome and you have to copy this url that you are getting this url okay so copy this from here also and once you have done that thing once you have done that thing come in this command line interface now to access remotely to perform all the things first time if you are doing you have to log in with your account login with the token you can see in my previous videos also and now i am showing you from here how you can push means how you can do all the stuffs how you can access it remotely all the things so for that the basic command here is get remote get remote then you have to add and then origin okay and after that thing you have to paste the url so if you click on paste you will paste the url so what is this git remote to get remotes means you want to access it remotely and then you are adding a new uh you can say origin is the name of this url okay this url name is origin means you are keeping this url remotely saving it as a origin like as you save in your contacts you can say or you can say in the to-do list you can save it as origin because next time when you you will be working remotely you can directly call this url using this origin okay okay and once you hit enter you will see it is added so now if you want to check that whether this is added or not you can simply do get remote remote e and simple v so you can see origin it is saved as name as origin and the url okay this url one is switch and one is push both the things i will be telling you what is fetch and what is push okay so now i think it is clear how we do these things now our commits are being made right now we want to put all them in the github so that my other friends can also see it so to do that we have to push it means what are there in our local git i want to push it in my github repository so for that simply i will do get push and simply you will do git push and then you have to give the place where you want to push that is our origin as we named you can name it anything you want you can do anything you can give your name also okay so now you are doing get push i will do origin okay origin and then the branch you want to push means we are in the master branch right we can also push our test branch so i want currently to push my master branch so i will give master i will give master i will hit enter you will see it is loading and it will be pushed so now if you come back on your github in the same repository if you refresh it right now you will see all the code that you did app.java all the thing is coming this one right all the things are coming and you can see master branch is here no other branches are present at this point so now let us say that you want to push the test branch also you want to push the test branch also into your github side by side right so for that you will simply do get push uh origin get push or agent and you will say test but from master branch how you can push the test branch you can't do it right so first you have to check out so i will write get check out test in the test branch i am clearing all the things so now you will do get uh what you will do you will do get push or eg or region and then you will give test if you hit enter the things will be performing and it will be pushed so if you open this uh thing right now in the github and if you refresh it you will see in this master if you you can also see test here you can also change your branch from here and if you want to see the comments you can see nine comments that was previously there right that was previously made by us if you change the branch also to master you can see all commits that we did which was in our local get it is now hosted and your other friends can also see this thing if you make this public if you made this private no one can see it only you can see it if you make it public others can also see this one so that is how we do get on github right now i want to uh show you one more thing in this tutorial only let me show you like fetch i told you push now i want to show you fetch to fetch the things like say i am changing something here say i am removing this hello world from my github like say your friends made these changes and you give some comment and it is being committed so only one line is present in the master now how you will get uh this thing in your local machine say in this app.java file presently this line is present right but how you will get these things right that i have removed online right like your say your friends have taken this thing and they have removed this thing right now how you will be able to get these changes so that is specially known as pull you create a pull means all the things that are present you fetch it in your local machine so to do that thing i am showing you how you can do that thing so first thing come here right and as i showed you this thing right so this is our tutorials folder and inside that app.java is present right in this place so what you have to do is like if i open this in vs code you can see there are two lines and i am currently in my master branch right so now once i will we have to write here get and after that we have to give pull and then the save to what we have saved the url that is origin right origin and after that we have to give the branch like in which branch we want to create it right so because there are two branches so we have to give the master branch because we have made the changes in master so we will simply give the master and it will make the changes so hit enter and now you will see that it is performing the changes and in this side you will see the code has changed so like whatever your friends or other persons or your team members will do you can pull it and you will get the changes at this point right so that is how you can get what other like when you are collaborating with other team members and whatever things they are doing so if you like uh make other changes like if you see here get pitch okay and if you save this one click on commit i am not giving anything in the message i am change this right so now if i run it again so you will see here is presently get conflicts so if i do it again get fetch sorry get pull get pull and then origin and then master and if i hit enter you will see it will perform the thing and it has changed to get fetch so whatever things will be done you can get easily in your local machine so that is why we especially use get with github so that we can do open source contributions easily right so this thing is now i think it is like almost clear to you how we work so that is how we actually work now let us say that you want to do some open source contributions okay so you want to do some open source contribution how will you perform that thing how will you perform that thing so let me show you one thing so you here you can see this is anki droids uh account and there here they have a anki android okay and this is the main thing it is an android app now what you want is like you want to contribute to this open source project so what you can do so for that you have a fork option and you create pull request whenever you make some changes now see one thing like if you get the direct access to this so you can make any changes and it is a dangerous thing like it will damage all the code like you anyone can come and can make changes in the code so that is not possible so for that to contribute especially only the owner can access this one and if the owner accepts your changes then only it will be merged or you can say the main file will be changed according to your ones so to do that thing you can simply click on fork here and once you click on fork it will create a repository on your account you can see the with the same thing anki android and your account so this is my account so it has created in my account so you can simply do this thing like fork any uh anyone's repository you can fork it and after you forget all the code will come in your own repository and now you are the owner of this code and you can perform anything you want in this code okay you can perform anything you want in this code now say that uh something has changed so you can see like in the anki droid this one from where i had four this one so let me open both of them so it will be clear so in this side i have the anki droids account where they have android and in this one i have my account where i have the same thing which i have forked now what you will see is like some other members are also contributing to this project like 275 contributors are there now like say someone is contributing to this project and you are also fought and you have also fought this one now what changes they are making how will you get all the changes in your repository that is owned by you right so to do that thing there is a fetch upstream so you can uh come here and there is option fetch and merge so you can see feature merge 363 upstream comments in anchor droid master so there are three six three commits which are being made so you can simply click on fetch and merge here so it will merge the current thing that are being changed here into your ones so like say if someone other one changes in the angular android and then you can also access the code in your one and as i told you you can pull it in your local machine so all the changes will be present okay and also you can pull it directly from this one also by giving up stream so that method i'm not going to show you i am showing you like this so you can like uh fetch and merge simply it will fetch all the comments and it will do like it has updated and now if you uh in your local machine you have already set up you can pull it like as i showed you a few minutes before how you can pull the code right now what is a pull request let us try to understand what is a pull request now say you have made some changes in your code like you are coming in the anki droid you are here you can see some issues are there like contributing to open source and like say that delete button this one good fit issue opened four days ago right so these are some issues that are open like say if you want to work on this issue or say you are working on some functions or something i'm showing you as like this so it will be easy to contribute in the open source like say this one so delete button okay so now you want to work on that issue so for that what you can do is simply work on your own and then like you have make some changes and you have you think that you have fixed that issue okay and now after that if you have make some changes like say here anki android so in the um i can come here also like say here in the read me and let me edit and read me so that i can show you so let me remove anki android rishabh i'm changing it to ratio and i'm giving a commit right so i'm giving a commit and now this thing is done so if i come back to code and if i see this one anki android reserve so like i am showing you basic things like you have make it changed here try to understand the thing like now you want that you want to create a pull request that hey i have changed some part like a good fist issue and now i want to push it so here you will see welcome to pull request now create a new pull request you can create a new pull request and then you can see that this line i have deleted and this line i have added and now you want to create a pull request so for that here you can see that base repository is the anki droid one master and my one is a head repository in my account so i want to call this pull request from my to there so now if you create a pull request here you can give issues tags and all these things so that people can understand what you issues are you fixing okay so you can simply click on create pull request and it will be done now i am not showing anything okay so i'm not doing this one because this is not a valid but this organization is a good one so i'm not showing so that is how basically you can create a pull request how you can edit and how you can push the thing so now i think that this thing is almost clear that how pull request works also like if you work on big projects then like some few people's like can work with you and you might face conflicts so as i showed you in local git how you can manage the conflicts same way you can manage conflicts at github also right same thing happens all the things the same only that are hosted at a local repository git and github is basically where all the things are hosted where you and other can also contribute right so that is the basic difference the things are almost same everything creating a pull request how you can get the code all the things are now i think clear so connecting to github i have shown you in github how you can correct then get push requests branching in github merging fetch request world request all the things are done so i think that uh today for this get get appreciation this is almost like good to go now you can start your open source contribution easily after seeing this video and if you face any problem regarding this video like if you are having any issues you can uh like you can do a comment in the comment box or you can also come in my instagram account and you can message me like hey i am facing this problem can you please help me and i am always there to help you guys right because we are building our community of all the people like who are new to this coding journey so subscribe my channel if you are liking my videos and share it with your friends right so those who are new and uh they can also learn from my videos right and don't forget to give the like button if you like this my videos and that's all for today and i would meet you in my next video to see me in my next video uh click on the subscribe button and hit the bell notification so that whenever i will be posting a new video you will get the first notification right so that's all for today's video and i hope that it is totally clear kit and github complete and you can also after seeing this video you can also start your gsoc right which is the important open source uh program so yeah that's all for today's video and i will meet you in my next video so till then bye bye have a great day [Applause] [Music] you
Info
Channel: Rishav Chanda
Views: 3,439
Rating: undefined out of 5
Keywords: git, github, branches, forking, pull requests, complete git and github, complete git commands, complete git guide, complete git tutorial, complete git and github course, complete git and github beginner to expert, github tutorial, git tutorial, git and github, git and github complete tutorial, pull request, open source, git github course, full git course, github pull request, git tutorial hindi, github tutorial hindi, github how to push, git remote, git bash, git branches, bash
Id: IxCyFFlWxPA
Channel Id: undefined
Length: 78min 43sec (4723 seconds)
Published: Sat Feb 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.