Thursday 11 July 2019

Introduction to GIT


What is Version Control System?
Version control system keeps track of the changes happened on a file (or) set of files.

What can you do with a Version Control System?
a.   You can commit the changes
b.   You can revert the file (or) files to a previous committed state
c.    You can compare different versions of the same file.

Problems with Centralized Version Control System
a. Centralized Version Control system has downside of single point of failure, since all the data is stored in single centralized server, if the server crashes, then you lost everything unless you maintain a backup of your data.

b. If the centralized server is on maintenance for some time (or) temporarily unavailable, then users can't commit their changes.

Distributed Version Control System
In Distributed Version Control System, every client maintains the mirror image of the repository, including entire history of all the files.

How git stores the data?
Git stores the data in the form of snapshots. Whenever you commit any file (or) save some data, git takes the entire snapshot of the system. For the non-updated files, git do not store the content, instead of that, it stores the reference (just a link to the previous identical files) of that files.

Let me explain with an example.



As you see below image, Git repository has 3 files initially.

File A, C are updated and committed. Now Snapshot is changed like below.




As you see the image, since file B is not changed, snapshot is referring the original file B, but not storing the actual content.

Assume File B and C1 are updated and committed. Now snapshot is changed.





As you see above image, since file A1 is not changed, snapshot is referring the original file A1, but not soring the actual content.

Assume File A1 is updated. Now the snapshot is changed like below.



As you see above image, since file B1 and C2 are not changed, snapshot is referring to original files B1 and C2, but not storing the actual content.

Git operations are faster
Whenever you checkout a git repository, it copies all the repository contents including repository history. Since total repository history also copied to your local file system, whenever you want to see the history of git file, git no need to contact the server, it gives you the information from the local history. Like this, you can compare different versions of the documents, changes done by other users etc., without contacting the server.


Previous                                                    Next                                                    Home

No comments:

Post a Comment