Hello developers, before diving into git, everyone wants to know the important terminology called VCS (Version Control System).
What is Version Control ?
We're all going to collaborate on a project together - How ?
A version control is a system which allow us to keep track of our works, when and who did what changes to our files. That can be a code, configuration, images or whatever we need to track.
Why Version control ?
It also let us easily revert any changes if it turned out not to be a good idea. It makes collaboration so easier by allowing us to merge changes from lots of different sources. Collaborators can work in parallel and merge their changes automatically, instead of manually comparing the differences between a file. It can also be called as SCM (Source Control Management). There are several version control systems in this world, but the most frequent and popular one is “Git”.
First you need to install Git in your local machine,
To install Git in linux, you can simple use this command,
sudo apt-get install git
To install Git in windows, visit
Once you installed git in your system, you can check your installation through this command
If you are using Linux means, go to terminal, If you are using Windows means, you can use git bash or cmd to verify your installation,
git --version
Yes, Now the VCS git is successfully installed in your system, Initial setup :
You need to configure git with your username and email
git config --global user.name “Yourname”
git config --global user.email “me@example.com”
Use of --global
is to set this values for all git repositories.
Yup, we configured our git successfully, Before moving forward, We need to know some terminologies called Working Directory, Staging Section, Git repository.
Working directory :
Simply our working place where you are doing any modifications. I would like to enlighten you with a simple example for a clear idea. Consider a chocolate manufacturing factory, which contains a manufacturing section where all the chocolates are made or adding any ingredients (Working Directory).
Staging Section :
Once the chocolates are made, that should be sent to the package section for getting the final product, right ? How you send your product to the package section either through automatic rope or any carriage, where the products are moved one by one to the package section. (Staging Area/ Staging Section).
Git Repository :
The packing section, where the items are packed and wrapped to make a final product and contains the entire logs of the products. (Git Repository/Remote Region).
I hope everyone will get some idea about three stages of Git , Now coming to our terminology, Whatever you need to work, you need to take the file from git repository and do your work on working directory, Once you made all the changes you need to put your file in staging section for saving(Committing) your changes to the git repository. Here Saving can be relatively called as Commit.
We can make edits to multiple files and treat that collection of edits as a single change, which is commonly known as a commit. In git terminology commit means taking a snapshot of your changes.
We completed our installation successfully and understood the main concepts of git. Now, we will discuss, how to use, commands to play with awesome tool called git.
To use git, the folder should be as git repository, to initialize a folder as git repository,
git init
Now, our folder is going to be tracked by git and our repository is in working directory. You can add a new file, modify the existing file.
After doing CRED operations, we need to move our files from working directory to staging section.
To add a file to the staging section,
git add FILENAME
To add multiple files, use *
git add *
Finally, we need to move our files from staging section to git repository,
git commit -m "COMMIT_MESSAGE"
-m is a flag for message. That means whatever comes after -m is a message explaining your commit.
Note : Commit message should be very clear and understandable to everyone.
You can check your status, by using status command
git status
You can use this command to check where your files are currently? What changes we did etc.,
You can check your previous commit history, by using log command. It will show the recent five commit history along with their commit ID, commit message, date and time of the commit.
git log
If you wish to know about particular commit (i.e) What changes are made in exact commit ? You can append your commit ID along with log command.
git log YOUR_COMMIT_ID
When you're ready to push your local changes to your repository on GitHub, you'll use,
git push
Now you are subjected to enter your github username and password to push your changes.
To pull the changes from github to your local repository, Use pull command
git pull
To clone the entire repository to your local system.
git clone REPOSITORY_URL
These are the basic things we need to understand about git. The best resource to know more about git is absolutely git documentation . Finally I wish to finish with my git quote !!
I committed to git, Which helps to keep track of my life !!