Git vs GitHub - Understanding the Difference
Tags: git, github
Published: 2020-10-07 00:57:29

# Introduction

Git and GitHub have an important role not only to open source but in the daily lives of several developers and companies. However, do you know what Git is? Do you understand what is GitHub?
Do you know what differentiates one tool from another? If your answer is no to any of these questions, don't worry because you're not alone.

In this post you will learn what Git is and what GitHub is, some of the features that each one offers and the relationship between them.

# What is Git?

Created by [Linus Torvalds](https://en.wikipedia.org/wiki/Linus_Torvalds), the father of Linux, to the development of the Linux kernel and maintained since 2005 by [Junio Hamano](https://pt.wikipedia.org/wiki/Junio_Hamano), Git is a Distributed Version Control System (DVCS) that allows you to observe and control the changes in your code. It is a very popular DVCS and used in many projects because it is multiplatform, free, efficient and easy to use.

A version control system like Git allows you to track, review and manage the versions of your projects and even reverse errors that could happen during development, such as deleting some important part or breaking some functionality during the implementation of a new feature.

We say that Git is distributed basically because it allows that multiple people, regardless of their geographic location, to have a clone (a copy) of the main repository locally, with all the commits history. This way you can make your changes, upload to the main repository and all other collaborators will have access when they update their copies of the repository.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pfsy53og7joijh0do994.png "Repositories Distributed Architecture")
Some of the Git's features are:

- Branch: the branching model is the crown jewel of Git. This feature enables you to create an isolated environment from the main one and experiment in any way you may find better without compromise the main repository. After you confirm that your solution works, just merge it with the main branch (since 01/10/2020 the master branch was renamed as main branch by [default](https://github.com/github/renaming)).
- Stash: do you need to change branches but don't wanna make a commit yet? Then, use stash to store all the changes you made, switch context and return later at the same point where you left off;
- Staging Area: it's a middle area in the Git workflow. It allows you to control which files will be added to a commit;
  ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9n91auxr7acby56ko6b6.png "Git workflow: Working Directory -> git add -> Staging Area -> git commit -> Repository")
- Bisect: the bisect command uses binary search within the commit history to look for which commit a bug was inserted into the project;

# And where does GitHub enters in all that?

I'm glad you asked, GitHub is a platform created in 2008 and purchased by Microsoft for the small amount of [7.5 billion dollars in 2018](https://news.microsoft.com/2018/06/04/microsoft-to-acquire-github-for-7-5-billion/), it gives you a way to manage and host your git repositories in the cloud. But that's it, Git doesn't need GitHub, but GitHub needs Git. You may keep all your projects with git local if you prefer, GitHub acts only as an alternative to keep a backup of your project with Git outside of your machine, in addition to making it easier to collaborate and share your project with others.

There are other platforms that compete with GitHub like [GitLab](https://about.gitlab.com/) and [Bitbucket](https://bitbucket.org/) that also allow you to save your project with git in the cloud. However, GitHub is simply more popular, as basically all devs have an account on the website to manage their projects.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f8v21n2bj5bhontsp50f.png "Cloud-based platforms to host Git repositories: Gitlab, GitHub, Bitbucket")
GitHub has a range of features, such as:

- Hosting your code in the cloud;
- Visualization of the commit history;
- Pull Requests: basically these are requests to include code in the main project, they allow a review of what will be added and comments;
- Issues: collaborators and users may identify bugs or request features through Issues that are available for discussion and monitoring on GitHub;
- Continuous Integration/Continuous Delivery (CI/CD) flow with GitHub actions;
- Documenting your project through GitHub Wiki;
- Create static pages directly from your GitHub repository with GitHub Pages;
- Centralization and availability of the project allowing a simpler more distributed collaboration process, i.e, anyone can view, clone and make contributions to a project on GitHub (you can also limit who can contribute and view the project by making it private).