Note: “This is in no way a replacement for the official Git documentation which is so extensive and detailed enough. This is written to cater for those who have never heard about git or simply don’t have the time to skim through the entire documentation but rather need concise information about git”
What is git?
“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency”.
What is version control?
“Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later”
Why should I use Git?
I don’t know about you but let me tell you my personal experience. The way I used to manage my files(be it code or normal text documents) in my pre-Git days was as follows.
“I would make copies of my files so that I could modify one of the copies. The result was that I would end up with sometimes multiple copies of the same file and I would even get confused as to which was the perfect one”.
From the experience, you can see the following problems;
- You can easily loose track of what you are working on.
- It’s hard to collaborate on a single file with others.
- It’s not scalable. Imagine you have multiple files and you are using the same approach for each one of them.
So, how does Git work?
Git creates a snapshot of your files at any single moment.
A very important concept in using Git is to understand the three states that files pass through. Once you get a hang of it, you are good to go.
The three file states:
- Committed: This means that the file has been safely stored in the local Git database
- Modified: Which means that you have changed the file but have not yet committed it
- Staged: Which means that you have marked a modified file in its current version to go into your next commit snapshot.
So the basic Git workflow is as follows:
- You modify files in your working directory.
- You stage the files, adding snapshots of them to your staging area.
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Are you interested in Git? Let me in the comments section