Git and GitHub are the most important tools that a software developer must always carry in his toolkit.
Before diving into the specifics of these two, let us understand the basic workflow of a software development firm. Then you will understand why these tools will be useful in your development journey.
A company, say X, have several different projects. 3–4 persons probably might be working on a particular project. So each person will be handling different parts of the project. Say the project is to build a website. So one person will be working on the HTML side; other person will be working on the CSS ( used to prettify the website ) and the third person may be working on the back-end; that is the server side code which includes the databases and all.
After finishing each feature of the project, each of them will upload their code to a common folder in the cloud. Before the code is saved to that folder, it needs to be reviewed so that there are no errors in the code. The code reviewing can be done by other team members. If everything is OK, then we can move the changes to the common folder. Or else they can suggest some review changes. After doing the changes, and if the reviewers approve, then it can be moved to the main folder.
This is the basic workflow that happens in a company. Now let’s come to the specifics. The common folder in the cloud is called a repository or repo for short. The cloud in which the repository is hosted is the so-called GitHub. Hope you guys are getting a hang of it.
Now what is Git?
Git is a version control tool that helps a developer to track what all changes that he/she has done in his code. Take the example of a simple calculator program in your favorite programming language. The user inputs the first and second number and then the user selects an option; say there is addition and subtraction. According to his selection, the program returns him a result. If he selected addition, then the result will be the summation of the two numbers. If he chose subtraction, then the result will be the difference of the two numbers.
Now he developed this calculator program and saved it. Now he needs a new functionality to his calculator, say multiplication. So he writes a method that accepts two numbers and return the multiplied result back. After writing the new functionality, he saves it again. Now his boss says that the client doesn’t need the new functionality. He only needs addition and subtraction. So what does he do now?
He need to go back and remove the code for multiplication right? Since this is a small program, it is easier to do. In companies, sometimes a task assigned to a person will require making changes to several files. And after making all the changes, suppose the boss says that the new change is not necessary for now. What will you do? Will you go back and rewrite the code?
This is where Git comes to the picture. If we had used git for saving, then each time we save, it is going to be saved as a different save point. Remember we had saved our program after writing the addition and subtraction functionality of our calculator. Now think it was done using git. This will be saved as savepoint1. Now we add the new multiplication functionality. It will be the savepoint2. Now the boss comes and says that the new functionality is not needed. What are you going to do? Simple. Switch to savepoint1. Work done.
In git each of these save points are termed as hashes. Each hash is a 40 character long hex digit, since it uses SHA-1 algorithm to create the hash.
This is it guys. You have now understood why we use Git and GitHub. This article was intended to give you an overview of what it is. Now the next step is to learn the git commands on how to save the program. All the best in your development journey.