4. Architecture Of Git

4. Architecture Of Git

Table of contents

No heading

No headings in the article.

In the Git Architecture there are four areas:

First Area we can use the word/term Working Directory. Assume that the third area is the Local repository. So, between the Working Directory and the Local repository, there is one virtual layer/storage named the Staging Area. So, the second area will be the Staging Area. And the fourth area will be the Remote Repository.

So, in GIT there are four areas. We have to move our files/codes around the four areas only.

  1. Working Directory

  2. Staging Area

  3. Local repository

  4. Remote Repository

GIT has two types of repositories:

  1. Local repository

  2. Remote Repository

Usually, all the project's code will be available in the Remote Repository (Global Repository).

Whatever the work that the developer is currently doing it is mostly available in the Local Repository.

Assume that a developer created multiple files in the Working Directory. And now he has to commit those changes to his local repository. So, to do that he has to first add those files to the Staging Area / Index Area.

That is if new files are being created in the working directory.

And once the work gets completed then those changes/files have to be added to the Staging Area. So, for this, we have to use the command “git add”.

git add

So, we have to use this command to send the code/files from the Working Directory to the Staging Area.

Now, the files are available in the Staging Area.

So, we have to send the files from the Staging Area to the Local Repository.

So, to do this work we’ll use the command “git commit”.

git commit

That is, to send/move the Staged changes from the Staging Area to the Local Repository we will use the command “git commit

Now, if all the work gets over, we want to share/publish the changes/files to the Remote Repository, so that other peer developers can get the changed files. So, we have to send the files from the Local Repository to the Remote Repository. Therefore, we will use the command “git push”. Then, whatever files are available in the Local Repository will be updated in the Remote Repository.

git push

And from the Remote Repository, all the work is going to be shared with the other developers so that multiple developers can work collaboratively.

To send the files from the Local Repository to the Remote Repository we can use the command “git push”.

git push

Now, another developer wants the files from the Remote Repository to his Local Repository. So, he can use the command either “git clone” or “git pull”.

git clone

git pull

To bring the files from the Remote Repository to the Local Repository we can use the command either “git clone” or “git pull”.

Q. What is the difference between “git clone” & “git pull”?

Git Clone

Ans: Cloning means creating the exact duplicate copy.

Suppose a new developer joins the team and starts working on the project. So, he wants to copy the entire Remote Repository to his Local Repository. So, he wants to create a new Local Repository which is the exact copy of the Remote Repository. So, he’ll use the command “git clone”.

If we want the complete exact copy of the Remote Repository in our Local Repository then we require to use clone and the command will be “git clone”.

For the first time, we are required to clone the project, so we use the command “git clone”.

When we run the git clone, Git creates a new directory on our computer that contains a complete copy of the remote repository, including all branches and commit history.

Git Pull

Now, suppose there is a developer who is already working on the same project as the other developers. He is already working on some files. Now, the other developer pushes some changes/updates to the Remote Repository and that developer wants those changes only in his Local Repository then if any updates are available which are not there in his Local Repository then for that he will pull the code from the Remote Repository to his Local Repository.

If we want the updated files/codes from the Remote Repository to our Local Repository for this we will Pull the updates / updated files / newly added changes and for that, we will use the command “git pull

git pull is a command that you use to update your local copy of a Git repository with any changes that have been made to the remote copy since you last fetched or pulled. If you have made changes to your local copy, git pull will try to merge those changes with the changes from the remote repository.