Hello and welcome I'm Raghav and today we are going to learn how to get started with Git In other words, we will download, install Git and then add our project to Git and finally push to Git lab So this is going to be very easy and very interesting And if you have no prior knowledge on Git, do not worry, I am going to go very basic step by step and we'll start from scratch and you can follow this on Windows or Mac operating system So we are going to download, install, get add a project or a folder to get and commit and push the project to GitLab So let's get started And here step number one will be we have to download and install Git So download and install Git on your system So you can go to your system I'm on Windows I will also show you on Mac So here I will just go to Git SCM search for Git SCM on Google and you will get to this git scm.com Just go here and here you will find option to download Git Now this detects your operating system So I'm on Windows It is showing me for Windows If I go on Mac and just go to the same site and I'll go here, get SCM.com So here you can see it is giving me the option to download for Mac So if you are on Windows, you can download for Windows And if you're on Mac, you can download from for Mac So I will say download, get from this website and then install it And all these notes will be available to you in the description or notes section of this video So I will click on this download for Windows and this will start the download and it is a exe file I will go to my downloads folder and here is my exe file I will just double click this to start the installer and say next you can read all the license agreement and then say next I will keep it on my default location that is C program files git say next and then again, you can keep all these default values and here you can see all these options. So I'll just use as it is and say next So here you can see if you want to use Git and Git Bash or you can use this Just keep the defaults and say next and next And now I will click on Install This will install Git on my system and the command to check So this is step number two And in fact, you can also check in the beginning if it is already installed So I will show you the command that you can use to check your Git installation So this is check Git is installed on your system and the command is get space hyphen hyphen version This is hyphen hyphen version So this is installed Once it is installed, you can go to your command line or go to get bash So here Let me see if I have a get bash You can see I have got a get bash as well I can go here and if you run the command get space, hyphen hyphen version, you can see I'm getting the version of Git Now you can use Git from this Git Bash or you can also use from your command line So if I exit from here and I will go to my command line or command prompt and here I will say Git space. version and I'm getting the version of Git installed Now, in case you are on Mac, you can go to your terminal and just say the same command, Git space, hyphen, hyphen version.
Now on my Mac, Git is already installed If you are using Mac and you have not yet installed Git, you can just use the same procedure or if you still need some help, you can go to my website That is automationstepbystep.com And when you go to online courses, you can You will find a course on Git and GitHub So you will find it here under version control system And if you click on this, it will take you to my YouTube playlist on Git and GitHub And here you can see a tutorial here Getting started, install Git on Mac There is also a Windows tutorial But if you are on Mac, you can see this I will also copy this link and make it available in the notes for easy reference So I will create a references section here. and this is the link where you can get all those videos So we have done first two steps Now here Step number three will be run following git commands So now we will run some git commands Now in the earlier session, we had already created a repository on Gitlab So if I go to gitlab.com So this we had done in the earlier session and we had created our account on Gitlab So if I open my account, I will sign in So we had created an account and we had also created our project on Gitlab So now we will add run some commands and these commands are the first command I will run is Git config. hyphen hyphen global user dot name and here you will provide the username that you have used in GitLab So the username that you have used to log in in GitLab I will provide it here So I will say here Git config minus minus global user dot name and password This is my username on GitLab and hit enter So by this on this system, it has registered or stored this git username So it will not ask you the username always when you are doing a commit and push So we can just configure all this one time Now, if you run the same command without the username, it should show you the username that is added So if I run this command git config minus minus global user.name It is showing me the username So that means now it is added So you have to run this command and then run this command just to check the username is added Similarly, the next command that we will use is we will say git config minus minus global user dot email and provide the email that you have used on Gitlab So here I will say user.email and I am just giving my email that I have used for creating an account on GitLab and hit enter And again, if you run the command without giving the email, it should show you the email that is added And this is the email added So this is the command After adding, you can run this to check the email added Then you can also run a command like git config minus minus global and minus minus list Now when you run this command, it will show you your username, your email and will also show you your password So by running this command, you can check all your settings and all the values that you have set So this is the third step Now after this step number four will be and this will work exactly same on Mac You can just go to your terminal and you can run this So on Mac if I say git config minus minus global user dot name and sorry, this is config So you can see it is showing me my username here as well So the same commands will work on Mac So we have done this Now Step number four will be create a demo project or a folder So a project also is a folder where we have like project files and other things So we will create a demo folder End.
Then we will add to Git So I'm going to go to my Windows system and I will go to this project folder Let me create a new folder here I will name it Gitlab Go inside this and again create a new folder here and this I'll name it my first project You can name it anything So I have created a folder here Now this is the folder that we will add to Git and then we will finally push to Gitlab So here the commands that we will use is So the first thing is So this will be step number 5 Go to command line or you can go to terminal if you are on Mac or you can also go to get bash Anything will work So this is command line or terminal or get bash and CD or change directly to the location of the folder and run following commands So here we have to go to command line or if you are on Mac, you can go to terminal or if you have Git Bash, you can also go to your Git Bash For now, I will open my command line on Windows and go to the location of this folder so I can copy the location from here and here I will say CD and paste the location and hit enter and I am on this location now Now here just take care if you are on any other drive other than C, then you first have to switch to that drive So in my case, I was on C drive and my project location is also on the C drive So I could directly say CD and the location of my project or the folder If you are on some other drive, you can first change to that drive For example, if you are or if your project is on E folder, just say E colon and it will change to E and then you can give the location on E drive So for now, I will just continue with this So I am on this folder location A shortcut can be if you go to your folder and go to the address bar and here say CMD on the address bar, say CMD and hit enter It will open the command line on the same location where your project folder is So this is a shortcut that you can use Alright, so now I'm on my project locator on my project location on my command line and here to start Git or to start tracking this folder with Git I have to say so I also need to go inside this my first project Let me go here or as well That is a mistake I should go inside my first project folder And yes, now I am inside my project folder So the first thing you will say is Git init This is the command to initialize Git and you can see it says initialized empty Git repository here If you go inside the folder, you will see a hidden folder called.git created If you do not see this, you can go to view and say enable hidden items So once you view and enable hidden items, you will see this .git hidden folder created If you are on Mac, it will be the same command So for example, let me just create a folder here I will create a folder called Gitlab and create a folder called my first project and here on command line I will CD to this location of my folder and I am here and now I will say git init and the same message I am getting here If I go inside my folder, you can see a hidden folder If you do not see the hidden folder, just press Command Shift and dot on your keyboard So if you press Command Shift dot simultaneously. You will see the hidden folders here. All right, so this is the first command that you will use Git in it Now, once you have added your project to Git using Git in it command, then the next command we will use is just say Git status and this will show you you are on branch master and there are no commits yet So we do not have any changes or any files in the project to commit to Git. So let us go to our folder and let me create a file here I will create a simple text file and let us say this is readme.txt And now if you go back to your command line and say git status Now you can see it says this is untracked file readme.txt So this is the second command git status and you can add some file to your folder and then say git status Now After this, we have to add this file for that you can say git add and the file name that is readme.txt Now here if you have more than one files or multiple changes to add to git, you can just say git add and dot This will also work This will add all the untracked changes or all the untracked files So I will say git add dot And now if I say git status, you can see now it is showing in green That means It is now added and it is ready to be committed So git add dot is the next command that you have used Now we have to commit our changes for that the command is git commit minus M and give some commit message here So here I will say git commit minus M and I will say my first commit Now here in the commit messages, you should always give some meaningful messages so that it is easy for everyone to follow So I will just say Git commit minus my message and press enter and you can see this commit is now done So commit is done Now if you go to your GitHub Git lab repository, if you go to your project, you will see no changes are here So you can see still it is like same There are no changes here and that is because we have just committed our changes We have not yet pushed the changes or we have not yet added anything to our repository And for that we have to use a command Git push So I will say Git push and you can say minus you origin master or in place of origin You can use the URL of your repository So here I will say git push-u and I have to give the URL So you can just copy the URL from the address bar or if you click on clone on your project on GitLab, you will see clone with HTTPS and you can copy this URL So I will put this URL You can put in quotes and then the branch name is Master So as of now, we will have a single branch called Master If you have more branches, you can add to a different branch We will learn that later, but for now, I will just say git push minus you URL and Master and I will hit enter and let us see what happens now So this is asking me for my git credential So let me use it So this is for Gitlab So if you are asked, just give your username and password It may be for the first time and now you can see it has pushed all the changes 100% done and everything is done Now if you go and refresh your repository on Gitlab, you should see your changes here So now you can see the changes are here If I see here, this is readme.txt file here It shows my first commit which was done 2 minutes ago and now we are able to add our project and changes to GitLab So this is step number six, check project or files or changes added on GitLab So this is how you can use Git and commit push and change push and pull changes to GitLab We will also see more commands in the coming future And this is the beginning And in the coming session, we will see more on forking project, creating branches, using GitLab, CICD and many other things So I hope this all was very useful for you Please do hands on and also share your knowledge with others If you have any doubts or any questions, please write them down in the comment section below and I will try to answer you as soon as I can I hope all this was very useful Thank you so much for watching.