Hands on Git Part-2
This is my second article on Git. With the first article (Hands on Git Part — 01) I have discussed how to install and configure Git. Therefore it is recommended to follow the first article if you are not fluent enough about the installation process.
The diagram given bellow covers the core concepts associate with Git. I will discuss those concepts one by one from the scratch. After that you will be able to perform your Git tasks smoothly.

By going through the above diagram you can clearly observe that there is a movement of content (files) with Git. Let’s try to understand the core concepts using a sample project.
Development Environment
This is basically the directory in which you are carrying out your project inside your computer. As you know this contains all the content (files) relevant for your project. Now create a folder named as “hands-on-git” (this is the name of the sample project that we are going to develop in order to understand the concepts). Here the “hands-on-git” folder can be considered as your development environment.
Repositories
Git has two types of repositories as local and remote. At the moment I am going to discuss about the local repository and the remote repository will be discussed later.
Local Git Repository
Local Git repository is located inside your computer and it contains all the files. This also has some key features such as commit history and commenting when offline.
First you have to create a local Git repository inside your computer which is relevant for your project. You can use git init command to create the local git repository. Now go into “hands-on-git project” folder and issue git init command.
git init
Now your project has a local Git repository.
Staging Area
Staging area is located inside the local git repository. Purpose of the staging area is to keep track of all the files which are to be committed. Therefore you have to add all the required files from the development environment to the staging area. It is important to remember that any file which is not added to the staging area will not be committed. Hence this feature gives the developer control over the files need to be committed.
In order to understand this properly, create a text file as “Temp” inside the “hands-on-git” folder you have created. You don’t have to include a code content inside the “Temp” file because this is done only to understand the concepts. Now use git add Temp.txt command to add the “Temp” file inside the staging area.
git add Temp.txt
In case you have multiple files in the development environment to be added to the staging area, you can use the git add * command to add all the available files or if you only want to add some selected files you can add them by using git add Name-of-File1 Name-of-file2 (here make sure to replace the file names to relevant names).
git add *git add Name-of-file1 Name-of-file2
Now you can clearly observe that there is a flow of content from development area to the staging area.
“Does Temp.txt actually added to the staging area?” Once I first used the add command I had that issue. Here you can use git status command to check the status. With this command you can find information regarding, what files are modified and what files are in the staging area.
git status

Here you can observe that “Temp” file has been added to the staging are but still it is not been committed.
Let’s add a new file inside the hands-on-git folder as “Temp2" and then issue the git status command.

With this out put it shows that the newly added “Temp2" file is available in the development area but it is still not been added to the staging area.
Commenting
When you have added all the files into the staging area, now you are ready to comment those files. It means now you are going to direct the files from staging area to the commented files with the help of git commit –m “This is the initial commit message” command. You can use a meaningful commit message with respect to the commit that you are going to make.
git commit -m “This is the initial commit message”
git log commit can be used to print all the commits that you have done until now.
git log

The log will show the author of the commit, date of the commit and the commit message.
I will discuss further details about remote repositories with Hands on Git Part-3.