Let us now explore some basic git commands that are very useful for us in this specialization. There is lot more to get than what we cover in this exercise. To get started, go to a convenient location on your computer and then create a folder named git-test. Then, open this folder in your favorite editor. Here, I have the git-test folder that we just created opened in my visual studio code. Let me add a file to this folder named index.html. Now, you can see that I have added in some html code into this index.html file. Let's save the changes. Now, let's switch to our command line, on the command line go to that git-test folder, and let's initialize this folder to be a git repository. So, to do that, add the command line, type git init. Now, this folder has been initialized to be a git repository. So, this is over first git command that we have learned, git init. This initialize as the current folder has a git repository, and when it initializes the folder, it will mark that folder as a master. This is the master branch for my git. Now, let's not worry about branches and so on, we will not deal with that in this course. We will only be working with the master branch in this particular specialization. So, this would be marked as a master. Now, this is the initial point of our repository. The next command that we're going to look at is git status. If you type git status in the command line, it'll tell you the current status of the folder. So, let's do that, add the command line and see what you chose. On the command line type git status and read the information that is tapped out on the command window, you'll see that it says on branch master, so that as the master branch that we are on, and it says untracked files, and then shows index.html in red. On your specific computer, it may be using different colors or represented differently, but this is what it shows on my Mac. So now, this index.html file that we have just created in the this folder is now not been added to our git repository. So, let's go ahead and add that file to the git repository. So, to do that, we say, git add, and you can simply say "dot" which means that all the files in the current directory will be added to what is called as the staging area of my git repository. So, now if I again type git status, you will see that the file index.html is marked in green, and it says, changes to be committed there, and then shows the file name, and then so, that means that this file is now ready to be committed to my git repository. So, the next command that we saw was git add. By using git add, you can add file or folders to that staging area. So, once you add it to the staging area, then you can commit that snapshot of our folder status to our git repository. So, that means that when you do the git commit, what this command will do is commit the current state of our folders into our git repositories, so all the files has the existent that moment, once they have been staged using the git add, then they will be committed to a repository then we execute the git command folder. So, at this point when we execute the git command, then, our initial state will now be changed to the first commit to the git repository. So, let's go ahead and do that. Back at the command prompt, let's type git commit, and then we can even add a message to our commit, so I'm going to say, git commit minus m, first commit, because this is our first commit to our git repository. So, when I do that, it says, okay, one file has been added to the git repository and some other information will be typed out onto the command window. So, let's now check again, git status, and now you say that it says nothing to commit, working directory is clean. So, what that means is that the current state of my working directory or working folder has been committed to the git repository. So, your snapshot has been committed to my git repository. Now, I can type the next command called git log oneline, and see that it shows a number there, an eight digit number there, and then also shows the message that we've put into our commit, saying, first commit. So, that is the log of all the comics that have been put into my git repository. So, going back to our next git command, we saw that git log dash oneline will show us a brief log of all the commits. If you simply type git log it display a lot more detail information about all the commits. But this is sufficient enough for obtaining information that we require. Let's now come back to our editor here, and in visual studio code, so I'm going to add more changes to my index.html file, so I will add. So I have changed my index.html file. Now, let me add another folder under the git-test folder. So, I will create a subfolder here named templates, and inside this templates folder, I'm going to create another file named test.html. This is just to show you how git can commit entire folder hierarchy into its repository. So, with test.html now there, I'm just going to copy everything from my index.html into my test.html, and save the changes. Going back to the command line, let's not check out the status of our git repository and this folder. So, typing git status shows that the index.html file that we have already added earlier to the repository has now been modified, so there is a newer version of the index.html. Also it shows that there are some untracked files in this folder called templates. Let's add all these changes to the staging area. So, again type, git add. and then all these files will be added to the staging area. Again, checking out the status, you now see that the changes that are being added to the staging area. So, all these files have been added to the staging area. Let's do one more commit. So, I would say, git commit minus m. Second commit, and then let's check out the log. If you check out the log, you'll now see that there are two commits in my git repository; the first and the second commit, and note that each one of them is given a different number there. If you want to see the full details of the log, you can type simply, git log, and then you will see more details in there than what you would be interested in. So, notice that the one line commit only gives the first few characters of my commit number there. That is sufficient enough for us to operate with. Let me now go back again to my Visual Studio, and just add one more line to my index.html file. So, now my index.html file has been modified. Let's save the changes. Going back to the command line, doing git status shows that the index.html file has been modified. So, let's add this to the staging area and then do a third commit. So, let's say git add dot git status. Now, you'll see that the index.html, the modified version has been added. Now, we can say git commit, third commit, and do git log oneline, and you'll see that there are three commits in our repository. So, now our repository contains snapshots of three different points. At the end of the first commit, at the end of the second commit, and at the end of the third commit. Now, we also can roll back changes, we can revert the repository to a previous version, we can pull out a file from an older commit and then replace the existing file directory from the old commit. So, let's see how we can operate with these things by learning a couple of more commands. At this stage, our index.html file is in the current state. So, you can notice that it has an h1 and two Ps. Let's now look at the next git commit. The next git command that we're going to learn about is git checkout. So, this checkout command allows us to check out a file from a previous commit in our git repository. So, if we don't like the current file that we have in our folder and we want to go back to a previous version of the file, we can always check out the file from a previous commit or from the current commit, and then continue to work with that file. So, let's make use of this and see some further changes to our git repository. Going back to our command line, we remember that between the second and the third commit, I made changes to my index.html file. Suppose I want to revert back to the index.html file from my second commit, so, then I can simply say git checkout 900cfcf. So, that is the commit identifier. The number that identifies that particular commit, and then I can say index.html. And what you would notice is that that older file will now be checked out into my current working directory. Going to my Visual Studio code, you'll now notice that my index.html file has reverted to the previous version. So, the changes that I made before the third commit is now gone. So, my index.html file has been restored to by its state at the end of the second commit. Now, at the command line, if I type git status, you'll notice that this index.html file which has reverted to what it was at the end of the second commit, it has now already been staged. So, using this git checkout, will pull out an older version of the file and then replace what is in the current directory and then it will also check it into the staging area. So now, if I do that and then I realize that this is what I want, I can simply do another commit at this point and then that file can be committed as default commit. But suppose I don't like this, I want to revert back to the index.html file at the end of the third commit, then all I can do is say, git reset HEAD and index.html. So, at this point, what happens is that the index.html, the modified version that I have checked out is still there, but this file has been unstaged from the staging area. If you go back and look at the index.html in your editor, it will still show the state at the end of the second commit because we had pulled out that file using checkout for that. Now, if you want to revert it back to what it was at the end of the third commit, then we do one more check out from the third commit, going to our RAM command window, type git status and you would notice that the index.html is marked as modified. But it also shows this particular statement here, it says, git checkout minus, minus and the filename to discard the changes in the working directory. So, that's one way you can discard the changes that they are made to a particular file corresponding to the previous commit. So, let me restore this index.html back to what it was at the end of the third commit. So, to do that, I would simply say git checkout minus, minus index.html. And then if I do git status, it shows that my directory is clean, and basically my directory has been restored to the state at the end of the third commit. Going to the file in my Visual Studio code, I see that their file has been restored back to what it was at the end of the third commit. So, if you have made changes to a file after they commit and you want to just discard those changes, you can simply check out the file from the last commit, and then all your changes that you've done after the last commit will be discarded on the spot. So, these are some basic commands that are very useful for you as you go through the courses into specialization, because you may want to commit at the end of each exercise. And as you proceed forward, you would still have a committed notion of the state of your folder at the end of the previous exercise. So, that way, if you are cutting out a new exercise and you discover that you've made mistakes and you want to revert back to the previous commit, you always have a way of doing that using the commands that we have just learned. So, with this basic understanding of these few git commands, we will be able to proceed forward with understanding and using git in the courses of this specialization. So, now, we have reviewed the git reset for a specific file or git reset in general. If you simply type git reset, it will restore you back to the last commit. So, it'll reset the staging area to the last commit without disturbing the changes that you've done to your working directory. So, once you reset, then you can check out the previous version of the file that you have committed in the previous commit. So, this way you can restore your folder back to where you were, at the starting point of the previous commit. So, sometimes when you are going through an exercise and you realize you made mistake, you always have a way of reverting back to a previous version. So, with this commands, I think you're all set to go ahead to use Git in the courses of this specialization. So, at the end of this exercise, did you Git it?