GIT Version Control System

GIT Version Control System

This article teaches you what is staging area.

J.     GIT Components

The 4 main components of GIT.

  • Working Directory

  • Staging Area

  • Committed History

  • Development Branches

Now let’s see the Staging Area. Before the chapter, we create a sample project. In this chapter, we will fix some bugs and add some feature requests. For example;

Consider, I will fix some grammar mistakes in index.html, add styles and add cross-browser consistency. So, let’s see how to do that on the git repository? 

We don’t add these files together. We must add them one by one in the git repository. This is called a staging area. Let’s see how to do that.

In this folder (git-learning), consider I fixed some grammar mistakes in index.html and added a CSS folder. Within the CSS folder, I added a style.css file and a normalize.css file.

In the git repository, how do that bug fixing and feature requests?

This message says, we have to add index.html again in the git repository to update what will be committed. Another message says there are some untracked files in the CSS folder.

Let’s see how to fix that.
First of all, we have to add an index.html file and record the data of what we have done.             

git add index.html
git status

After moving our file to the staging area. then we can record our data in the git repository. How to add?

            

git commit -m ‘grammar mistake fixing’

 

 

Now nothing added to the commit. But untracked files in the working directory. How to move these files to the staging area? And how to move to the git repository? Let’s see.

 

We moved these files together in the staging area. But we don’t do that. Because we have to commit one by one to the git repository. That's Why I removed one file in the staging area. How to do that?          

git restore –staged css/normalize.css

 

After removing there is one file in the staging area. So we have to record that file in the git repository.       

git commit -m ‘color scheme change’        
git status

After adding the normalize.css file in the git repository

Now the working tree is clean.

Note: The staging area is a temporary area. It acts as a bridge between a working directory and a git repository. What is in the staging area will come to the git repository.

 

Note: What is the difference between git remove and git restore?

git restore –staged index.html: This command will restore the data in the staging area to the working directory.

git rm –cached index.html: This command will remove the data in the staging area.

 

If you want to interested in watching more videos about git. Please watch Appslanka git videos on our youtube channel. https://www.youtube.com/playlist?list=PLZmKantulzuSeqMy-zM56ZC0S7watreeu. Don't forget to subscribe.


 

0 Comments

Leave a comment

Your email address will not be published. Required fields are marked *