Git in simple words

Hello there,

Gone through a lot of information on the Internet and still unable to figure out what version control and git is all about? Or are you like me, who knows and has worked with git to a decent level, but get confused with the basics now and then. Well, be any reason you come here for, I have tried to put down my understanding of Git in the simplest words possible.

Say you have a project x you are working on. Project x is about a website you want to make as a portfolio .You are happy with what you have built. It’s functioning perfectly with no issues. Now you have an idea, say you want to add a button on clicking which one can send you a message “Hello, I visited your site” as a mail. You have this idea, but don’t know how to execute it, if it’s even possible to do that, will it work or not! You don’t want to spoil your beautiful project x just because you are greedy for a new feature. You think, “ should I create a duplicate project, experiment there, and copy paste changes if it’s successful.” Possible. But not a clean way. That is where version control system comes as a savior. And with this power of fulfilling your wishes of being greedy and tidy simultaneously, it comes with a lot more powers.

Git is a version control system. You can use it on your system without Github, Bitbucket or other hosting sites. Using hosting platforms like Github means maintaining a backup online with some extra features that these platforms might provide. It is not a necessity for Git itself.

There are 3 spaces to understand when you include git in our project. This is all that we’ll be talking about in this blog. These spaces are

  1. Working directory
  2. Staging area
  3. .git directory

Working space means everything you add, delete, edit, happens in this space. So whenever some file or folder changes, it’ll automatically be under the working space. The Staging area is where your work goes when it is prepared, but still not given a final green flag. The green flag, the final version goes to the .git repository (after we commit it). For eg. You designed the button’s UI. Kept it black, then changed it to brown when it wasn’t much pleasing to the eyes. At this phase your code is in working space. After 5 color changes, you are finally happy with cyan. But still it’s just a small step done compared to the whole functionality that you have to implement. So you add these changes to the staging area. And you continue working in the working area. When your whole feature is developed, you add all of it to the staging area, bits by bits as the button, or in one go, that’s your choice. On completion, you can add your code to the .git repository. Git saves a snapshot of the files in the .git repository and the flow how these files have changed from time to time is in a tree like structure.

So this is the first thing you should know about git. All the commands about how to do this, will be easy to understand once you know what these three spaces are. Drop in your views in comments below.

PS. Suggested improvements appreciated.

Happy learning.