Part 1-Git And Github Series- Introduction, Installation Of Git And Understanding Basic Commands

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys so this is a series of videos to understand about git and uh you know in this series we will try to understand that what are the best methodologies to commit the code in into a specific repository because in iit companies you know that in your specific team you know you'll be having many people you'll be having front-end people you'll be having people who are working in the back end let's say you'll be having an ai team people right and many people will be developing or writing a lot of codes and they have to make sure that when this code commit is actually happening in the main repository all needs to be in sync and we really need to follow the best practices that is available with respect to committing our code into the repositories so in this series of videos we are going to understand about git along with that we are going to take up github repository and we are going to make sure that whenever suppose if i am developing a specific project how the commit should basically happen again i said this will be a series of video this is the entire check sheet that i am going to cover one by one from top to bottom okay probably in four to five videos we'll be able to do it first of all to start with what is git git is a free and open source distributed version control system that's responsible for everything github related that happens locally on your computer this basically means anything that locally that you do if you really want to commit that into a specific github repository i can definitely use get okay and many many companies uses get and it is the most common open distributor source distributed version control so uh what we are going to do initially is that please make sure that you have a github account uh let let's say that i'm going to create a new github repository okay and then we'll try to just see how to just commit or push your code into the github repository so let's say i'm going to write something like git tutorials okay so this will be a get tutorial series uh there will be description no need to write any description no need to add a readme file no need to add git ignore file or no need to add a choose a license anything as such you know later on we'll keep on adding and we'll try to see that how things will come up so i'm just going to go and create the repository now once we create this repository the next thing is that since we really need to work with get we really need to install the git tool itself so in order to install it first of all go over here search for git cli so in git cli you'll be able to see the download section now inside the download section go and select and download the git tool with respect to your specific operating system so suppose if you have mac os go ahead with this windows linux or unix go ahead with this suppose i want to go and download for windows so i will go and click on download for windows so once you download it here you'll be able to see some kind of exe file just double click it click on next next next next and all the installation will take place now in order to verify whether your git tool has been installed or not just open your prompt or command prompt or your terminal in linux or mac and just go ahead and check what exactly it is so here if i probably go and see get version right here you'll be able to see that okay fine if get version is basically coming that basically means git tool has installed okay now what i'm actually going to do is that i'm just going to create some files locally and i'm going to commit that specific files in this specific repository now in order to commit it here you can see nothing is there you can commit it through two ways one is create a new repository on the command line or push it in the existing repository from the command line or you can also import code from another repository like this all repositories is also uh you know it handles that subversion mercurial or tfs project i've worked in tfs long back okay but we'll focus on this too okay and then we'll try to see how to commit it now here you can see that we have not created any readme file but it is a good practice that we should create a readme file in our repository okay so uh what i'm actually going to do i've created a readme file over here you can see in this particular folder uh here this readme file i will try to commit it into this particular repository so let me open my command prompt again okay and let me go to this specific path so i will go to this path and then we'll initialize uh over here let's see so i'm just going to go to the g drive and clear the screen okay now to start with what i'm actually going to do first of all i have to make sure that this is what is the entire get that we are going to initialize over here so we have to first of all initialize our git so if i write git init here you will be able to see that initialize the empty repository get repository right now if i probably see my dir in windows so here you will be able to see all the files okay but make sure that when it is initializing right it also creates this hidden folder called as dot get and this folder need not come get committed into the github repository okay this is just for your configuration or other configuration itself now to begin with what we are going to do is that first of all always remember since we really need to commit in this github repository okay we have to first of all set up our basic configuration now this configuration is with respect to your user dot name and user dot email id so that it will be able to authenticate and it will be able to understand okay i need to commit it over here so in order to do that just search for get global config so first tutorial that you'll be seeing we have to set up this two things okay that is your username and your user.email and how to set it up just go ahead and write this particular command this email id should be the same email id that you specifically use in github okay so to begin with what i'm actually going to do i'm just going to open my command prompt and just see this particular command get config so here i'm just going to write git config okay minus minus global global and here if you search for user dot name so once you execute this right you will be able to understand whether you have done this configuration or not suppose let's say you are getting user dot name so here i am getting krishna okay so that basically means i have already configured if suppose you have not configured you can just write user dot name and here you can write something like krishna like how this methodology has basically been followed in the same way so here you can definitely write like this and you can search for krishnak or whatever your name is right so that is what you can actually use here okay now similarly once you enter this automatically this user dot name will be set up this this configuration file of this configuration key will have the specific name that is krishna similarly the next setting that you need to do is user.email in the user.email just go ahead and write your email id like this okay now this will give you us like why we are doing this because later on when you push the code right it will ask uh for an authentication for this email id along with your github right so that also you can basically do so that is the reason why you're placing this so after you do this just press enter and just keep idle and then we'll start the i mean then don't do anything then we'll start the entire initialization process and committing process so now i'm just going to clean the screen now you have done the global configuration where you have set up your user dot name and the email id okay now the next step over here is with respect to this okay now already you know that i have created a file which is called as readme file now over here you can see that the first step is saying that okay by using this echo command specifically in linux terminal i have created my readme file okay now the next thing is that we have done already get in it now we are going to add this readme file and this as soon as i execute this add command understand if i probably go and search for git ad and always remember you have to follow the documentation there are some good documentation with respect to this one documentation here you can see with respect to git ad what are the possible options and there are some few options that we use regularly okay now what exactly this git add will do okay understand guys right now if i probably just search for get status so git status is a command over here just let me execute it so here you will be able to see if i execute get status so here you can see that in the get status no commit yet okay and right now this is basically the untracked files so here you can basically see that when i write git status here you can see something called as untracked files right now right now if i say untracked files this basically means this file has not been tracked yet by git okay now if i really want to track this file and track make sure that all the changes are also tracked along with that first of all i will go and add this git file so git add readme dot md so once i execute this now this file will get tracked so if i now see get status here you will be able to see that okay changes to be committed so these are the file new file that needs to be committed to the staging environment okay now staging environment is just a kind of environment which will make sure that uh like let's understand like if you are sending some files that needs to be pushed to the repository at that point of time initially will stay will send it to the staging environment and from that stadium environment it will then push it to the main github repository now what we are actually going to do over here is that first of all after uh you know after this specific step is basically happened that basically means we added this readme file the next step i will just go and open this kit tutorials now you can see that i can put my first commit now this commit will make sure that it will go to the staging environment okay so now let me just execute this so here i'm going to write git commit minus m and let's say that this is my first commit i'm going to write this is the first comment this is the first commit so once i write this and once i execute this now you'll be able to see that this entire changes have been moved to the staging environment okay and staging environment is just a kind of environment it's just like a playground wherein i'm keeping all the things that needs to be pushed to the repository the main repository now if i go and see forget status again here you'll be able to see that on branch master nothing to commit okay this is fine that basically means whatever i had to commit that is already there in the staging environment now if i probably go and search for grit branch right here you'll be seeing that this particular branch name is master okay please remember all this command i will try to show you in the form of story so that you'll be able to do this commit and all as you go ahead right now whenever you create any branches or whenever you create whenever you create your github repository you know by default there will be a branch called as main branch so one thing that i am actually going to do is that i am going to make sure that i'll rename this master branch and i'll write something like main branch okay so how to do that here you can basically see there is a command get branch minus m main okay so if i probably write get branch minus aim and i will write it as main branch so now once i execute this now if i clear my screen and if i write git branch here you'll be able to see that now my master branch has been changed to something called as main branch okay now we have done this it is very very good but how do we make sure that this local repository is basically connected to our main repository so once i do a git push it should be able to understand that which is the repository that i need to send it to okay so for that what i'm actually going to do i'll go back to my repository and i will copy this entire link see this link that you will be able to see this git link i will try to copy it now once i copy it here you will be able to see that i will be writing a very simple command and the command is also visible over here which will say git remote add origin to this particular value so that basically means from our local repository we are making sure that we are giving that we are telling something that okay this is the place where you really need to commit so here i'll just go ahead and write i'll say get remote add okay and i will write origin and then this will basically go to my git of my specific repository so here you can see that this has been connected right now if i probably go and see get status everything is fine no nothing to commit everything is there already in the staging environment if i write git remote this is super important get remote minus v okay so here you'll be able to see that currently in the local from where i am fetching and pushing so from my local basically means anything that i commit to my staging environment that will basically be in this original origin variable okay origin variable so this origin variable is basically indicating my staging environment now finally i will go ahead and push that my code to the repository so after for doing that i'll say git push from origin and the by default me the repository the branch in the main repository is nothing but main so once i commit this here you'll be able to see that the code will be going and this is basically saying that okay at this particular location it has already gone okay so i'm just going to you know reload this so in short over here it will create a new main branch and there the commit is basically going okay so second way is this one which i will be discussing as we go ahead okay now let me just reload this and here you will be able to see that i will be having my readme file with github tutorials by krish now the next step any changes that i make let's say i want to make some changes over here so i'll open my notepad file let's say on the same file i'm making these changes okay let's say i'm making these changes over here let's say here i'm writing one more line subscribe to fresh channel okay and i'm just saving it let's say there is some information in this readme file now as soon as i do this now see see the importance of tracking if i write git status you know that the file has changed here you can see that it is saying modified okay modify now there are two important option if you feel that this modification is correct you can add this file otherwise what you can do you can restore the previous file okay so if i write get restore okay readme.md uh okay restore for spelling is wrong but let me first of all close this file okay let me close this file now once i write restore and probably just execute this here you'll be able to see that the file will be restored how do i know that just open this open your notepad and just drag and drop over here now you can see that the further text that i have written probably by mistaken or nothing as such i don't want to do that cabinet you can also revert that or restore the previous file that was actually there in the staging environment this is perfect okay now let's say that i have made some changes and here also i'm going to say please subscribe to my channel to my channel then what i'll do i'll make this one file let's say i want to make one more file and this file is a text document file and let's say this will be test1.txt now here you can see that i have added one file and obviously readme file has been modified now if i probably clear the screen and write getstatus okay here you'll be able to see okay this file is modified and this file needs to be added which is basically an untracked file now since two files are there and i have to make sure that both the changes goes right so what i'll do i will write again git add now instead of writing the file name i have to make sure that both the things changes should go and all the files that are present inside all the changes should go so i can write dot so once i do that here you will be able to see that by using this dot all the changes will specifically go right so once we execute git add dot so what will happen both the changes will go ahead and now let's go ahead and see with respect to git status so now the git status says that okay one file has been modified and one file is a new file okay now we needed to do the commit so here when i do the commit again i'll write my message so i'll say this is my second commit okay and here you will be able to see all the changes are there now let me write gate remote minus v so here you will be able to see okay this is my origin this is my thing now let me just go ahead and push this so push from origin to main all right so once i do this here you'll be able to see one text document will also go now if i probably go and reload it here you'll be able to see one more file has come and here also it shows the information like how many commit has basically happened this is my first comment this is my second comment so if you probably see the commit details all the information changes everything you'll be able to see it so this is how a simple way we can actually do the commit with the help of command 9 prompt i will also be showing you multiple ways how to do this also okay now let's say there may be situation where you will be saying krish i already have this repository how do i clone this how do i clone and make sure that and make sure that everything tracking is basically happening let's say i create a folder over here uh my new folder okay and this specific folder since no need to create over here because again this folder will also keep on getting tracked so let's say i have one more folder i create over here and this particular folder will have some name get tutorial okay okay the same name so let's say this is my new folder okay now inside my new folder let's say i go to my open my command prompt okay i open my command prompt and here what i'm actually going to do is that i'll just go to this particular folder location so i'll say cd this one okay and let's say i've gone to my g drive so this is i'm in my new folder now let's say i want to clone this entire repository over here so in order to clone it what i will do is that i will go over here copy this okay and i'll say git clone clone and i will just put this kit so here you will be able to see in this particular folder location the entire clone will basically happen so here you can see good tutorials all the readme file and text one file now i'll again go to my command prompt okay i'll go to my git tutorials okay clear the screen now let's say that i want to create a new folder over here or new file over here so let's say i created another new text document and i really need to push this now again if i probably go and see git status over here you'll be able to see okay untracked file is there right so here what i did is already that there was a repository i cloned it now i want to commit in that same repository over here right so uh what i'm actually going to do after this is that just write git status i've already written so now get add dot uh then get commit okay minus m this is my third commit third commit okay and this commit has already went if i probably see my git status here nothing is there on the marine branch so the everything is there and currently what is my main branch if i really want to see if i go and write get branch here you will be able to see main branch okay and then finally i will try to push this from origin to main no need to write two now usually guys for the first time when you do this right get push origin main right it will ask you for an authentication since i have already authenticated it so you just have to do the authentication to make this push successful because you're there you really need to write the password and all okay so now you can see that the commit has actually happened i can again reload this page and here you will be able to see new text document again three commits this is my third commit so you can also clone this and you can also start the committing process okay now uh in this tutorial we have learnt all these things in the upcoming videos what we are going to do is that we are going to see how to revert uh the changes how to make sure that you know everything is tracked parallely i'll also show you the concept of branching i can i create my new branch you know because in a bigger project when you're specifically working you really need to create multiple branches when you're working and once the changes have happened you commit into that branch and then we do a pull request from there we merge it all those things as we go ahead we'll be learning right so i hope you like this particular video i'll see you all in the next video thank you
Info
Channel: Krish Naik
Views: 51,935
Rating: undefined out of 5
Keywords: yt:cc=on, git tutorials, git push, git status, git commit, git reset, krish naik git tutorials, github commit, git hub tutorials
Id: GW7B6vwktPA
Channel Id: undefined
Length: 20min 31sec (1231 seconds)
Published: Sat Jul 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.