When we learn about Git, first of all, we need to know what is Version Control System (VCS).
So what is VCS?Version Control is a System that records changes to a file or set of files over time so you can recall specific versions later.
Why we use Version Control System??
- Made a change to the code and need to revert back to a known better state.
- Have to maintain multiple versions of the software.
- Wanted to see the difference between two revisions.
- Wanted to test if a particular version is broken or fixed.
- Wanted to see how long a bug existed for.
- Wanted to experiment without interfacing with working code.
Git is a distributed version control and file management system.
- distributed version control means if there is a project that has more than one developer, they all have an own copy of the project. Therefore every developer can work offline and it becomes very fast.
- file management system means every developer can modify their own copy of the project. At last separate code will be merged together and get a finished product.
Follow picture shows an overall idea of Git data flow.
Now let's see what is above stages in brief.
1. Working directory:-
This is stage you are working. Here you will implement or modify your files. If you are satisfied with your implementation, you can take a snapshot or commit. So then later you can revert back and change in this working directory if you are not satisfied with your changes in your files.
2. Staging Area (Index) :-
If you want to save your source code in Git you want to promote or add your files to this staging area. This is some kind of a cache to save all your data in the working directory.
3. Local Repository:-
Once you all files are added to the staging area, you can snapshot or commit. So you can save your files in your local repository. Once that is done, the staging area is wiped clean. So if you wanna snapshot, you have to do this every single time.
4. Remote Repository:-
Above three steps are exist on your local machine. The remote repository is the place where all the developers gather who are contributing to your project. From all these files you can get the best product.
Once you all files are added to the staging area, you can snapshot or commit. So you can save your files in your local repository. Once that is done, the staging area is wiped clean. So if you wanna snapshot, you have to do this every single time.
4. Remote Repository:-
Above three steps are exist on your local machine. The remote repository is the place where all the developers gather who are contributing to your project. From all these files you can get the best product.