Understanding Git & GitHub

Understanding Git & GitHub

Overview

From tech giants like Meta and Google to the tiniest of startups, developers across the globe use Git & GitHub. If we plan on becoming a developer, using Git is essentially a must-have skill.
I understand that as a beginner, learning it can be very overwhelming because let's be honest - the command-line interface looks pretty boring to the eyes, and getting our hands used to the CLI commands can be very tiresome. But personally, the more I use it the more I understand how important & helpful tool it is. Let's get into understanding it!

What is GIT?

Git is the world's most popular Version Control System (VCS).
Version Control is a software that tracks and manages changes to files over time. Version Control Systems generally allow users to revisit earlier versions of the files, compare changes between versions, undo changes, and much more!

Git is one of the many VCS (eg: Subversion, CVS, Mercurial) which allows us to do almost all tasks like:

  • Track changes across multiple files.
  • Compare versions of a project
  • Time Travel back to old versions
  • Revert to a previous version.
  • Collaborate & share changes.
  • Combine changes.

How? Let's look at an example :

image.png

In Git we create checkpoints - they are files we can always get back to. Here I have created 1st checkpoint initialise which initialises the project we are working on. Now, I did some work on the project hence added more checkpoints - change 1, change 2, change 3 & change 4. This workflow is very common, as we add more changes to the project we add more checkpoints.
Now, what if we want to go back to a checkpoint for eg- change 2, and add some different kinds of changes to it? We can totally do that with Git.

image.png

Now, we are at the checkpoint change 2 before we added the checkpoint change 3. We can Branch off and start working from change 2 checkpoint.

Please note that - the changes that were previously added after change 2 has neither been deleted nor been removed. Hence, the work is not lost.

Now from the change 2 checkpoint, we added different changes to it from another branch - change 5, change 6.

What's the benefit of doing this?

  • If we look at it we have now created 2 versions of the same project:
    The first version has changes made in checkpoints - change 1 change 2 change 3 change 4
    The second version has changes made in checkpoints - change 1 change 2 change 5 change 6

  • We can even go back to the time when we added only change 1 in the project - That's the reason why the term "Time Travel" is often associated with Git. Fascinating, isn't it?

What's more fascinating is, we can even combine the checkpoints ie.. change 4 and change 6; the work that changes between the two versions we made.

image.png

Hence, we end up with a project which now has all the checkpoints combined.
This exactly is the sort of thing that Git helps us with.

Git != GitHub

Beginners often confuse Git with GitHub. Note that, Git is a VCS that runs on Control Line Interface (CLI) while GitHub is a Graphical User Interface (GUI) - a platform for hosting and collaborating on Git repositories.

Git

  • It runs locally on our machine
  • we don't need to register for an account.
  • We don't need the internet to use it.
  • We don't need to open GitHub to use Git.

GitHub

  • It is a service that hosts Git repositories (projects) in the cloud.
  • it makes it easier for the users to collaborate.
  • we need to sign up and create an account to use GitHub.
  • It's an online place to share work that is done using Git.


That's about it for now, I wrote this blog to introduce the readers (specifically beginners) to Git & GitHub in the most Laymen language I could. I'll be writing more on this topic, things that I know already or I'll be learning in future.

Let's make Git & GitHub less overwhelming to learn! :)