git-and-github-logo Have you ever wondered, how do the employees in any IT company would share their huge codebases with each other? How are they tackling the issue of continuously updating codebases from multiple employees? Don’t worry, I’m sure we will get to know the answers to these questions by the end of this blog.

What is Git?

Git is basically a Version Control System. What is that and why do we need it? Let’s take an analogy for a better understanding.

git-logo

Suppose that you are working on a project, and you want to add some additional functionality to the project. So to keep your current code safe, you might be copying the whole folder and then making changes on the new copy! For further modifications, you again make a third copy and then work on that one. But don’t you think that it is tedious and space-consuming? Of course right? That’s where Git helps us. We can create versions of our project using Git and GitHub. If something goes wrong in our future updated versions of the project, we can always roll back to the previous ones. The most important thing is, we don’t have to make a new copy every time we want to save any version of our project.

Hence we needed a system that will control the versions of our code! Git is a freely available version control system that tracks changes locally. By locally, I mean that it is a tracker of your files on your own computer. When you edit a file, git can help you determine exactly what changed, who changed it, and why! Git comes installed by default on many systems. You might have to download and installed it if it is not preinstalled in your system.

Now, let us learn some basic terminologies which will help us to have a better understanding.Any file which is been tracked by Git can be in these 3 stages.

Committed Stage:

Git remembers versions of our project as a snapshot. So when we commit our files, git takes a snapshot of it and in the future, if suppose we want to revert back to the current version, we can simply go back to the respective commit.

Modified or Untracked state:

After updating a piece of code or any data, git will immediately put those files in untracked changes because Git now thinks that the file is no longer in the same state as it was before!

Staging state:

We have to stage the untracked files in order to include them in any version of your project. Staging the files means, you are telling git that these files are now updated and ready to be included in a commit. So, when we commit, only those files which are staged will get committed, or else it will show us a warning!

Few Terminologies are:

1. A repository (usually abbreviated to “repo”) is a location where all the files for a particular project are stored. Each project has its repo, and you can access it with a unique URL. You can think of it as a folder on your computer.

2. Commit means Git takes a snapshot of your current status of the files and store it as a version of your project.

3. A pull is referred as to fetch and download the files from a remote(online) repository (i.e. From GitHub) and update the local repository so that project files are in sync.

4. Push is simply pushing the commits from your local computer to GitHub.

Apart from Git, we have other VCS too, like CVS, Subversion, Bazaar, etc.

What is GitHub?

github-logo

We now have a basic idea of how can we manage different versions of our project using Git. Although Git is not our ultimate solution.

What happens if our computer accidentally crashes? Or
What happens if all our data is lost due to some mess in our computer?


All the efforts of using Git would go to waste. A solution may be, we can put the files somewhere remotely i.e. somewhere online, like your Google Drive or google cloud or Onedrive, etc. But there too, the same conditions will arise, we will again have to upload the updated versions of the project regularly in separate folders.

That’s where GitHub comes in, we can think of GitHub as a cloud-based version-control system with the additional feature of collaboration with other developers. It is a code hosting platform.

One liner explanation would be, GitHub is a social media for code!

All the things which we can do with Git can be done with GitHub but on the cloud. The benefit of this is if our system crashes or somehow we lost our code from the computer, we can always pull it from GitHub.

Summary of workflow:

Git and GitHub work in coordination. Git provides local VCS while GitHub gives us cloud-based remote VCS. We do basic operations like modifying, staging, and committing the code files using Git on our computer. We then have to push the commits on our GitHub account so that we can save the project remotely as well. If we want to get our project files back we can simply pull them from the GitHub account.

technovanza

If you found this blog informative, kindly leave the reviews in the contact section above.