1. Overview

When it comes to programming, using a VCS (Version Control System) is inevitable. It’s one of the most crucial tools in a programmer’s toolkit. For a single developer, working on a one-time script, they can get away with not using one. However, for a team of programmers, we need a VCS for smooth collaboration.

One of the most popular VCS is Git. New programmers confuse Git with code hosting platforms like GitHub, mostly due to naming. However, they are two different technologies, albeit related ones.

In this article, we’ll learn the differences between Git and GitHub. We’ll cover what makes a version control system and why it’s necessary to have one. In addition, we’ll also learn about the code hosting platform GitHub.

2. Git

In this section, we’ll give an overview of Git and how it works. However, before learning specifically about Git, we should be familiar with what a version control system is.

2.1. Version Control System

In software development, VCS is part of Software Configuration Management (SCM). Version control is a way to manage and version project files. In essence, we manage the versions of the source code files, which are typically plain text files with appropriate file extensions. However, it’s not limited to just source code files.

VCS is necessary for the productive development and maintenance of a software project. It is one of the important cornerstones of collaborative software development.

There are mainly two types of VCS: Centralized VCS and Distributed VCS. In CVCS, the source code is hosted on a central machine that keeps the various versions of the code. Developers commit their changes directly to this server. It works well for collaboration but has a single point of failure because if the server goes down, all progress is halted.

CVCS

On the other hand, a DVCS allows developers to have a local copy of the source code repository, with all its history, branches, and tags. Unlike centralized VCS, the developers commit the changes to source code files locally, which enables offline work and faster operations.

DVCS

2.2. What Is Git

Git is the most popular open-source DVCS and was first developed by Linus Torvalds, the very creator of the Linux kernel. It was solely designed to help the Linux community build the Linux kernel. Later, it was also built for other platforms like Windows and OS X.

Over time, Git became popular in other open-source communities. Soon, Google made the switch from their in-house version control system to Git, and other tech giants followed.

Usually, we use Git in a terminal. It comes with a comprehensive set of options, and we can customize it further for different workflows and preferences. Though it has no official GUI, there are numerous front-ends available.

2.3. How Git Works

When we start a new project, we initialize Git for that project, which makes the project directory a Git repository:

$ git init .

It creates a .git directory inside the working directory. The working contains all the project files, while the .git directory contains the files’ history, branches, tags, and so on. Usually, it’s recommended that we avoid making changes directly to the files inside the .git directory.

As we work on the project codebase, we make commits. A commit is a snapshot of the repository at a specific point in time:

$ git add . && git commit -m "first init"

We checkout the commit to create a unique instance of the project:

$ git checkout <commit-hash>

Apart from that, a Git repository can have multiple branches. A branch is a parallel version of the repository. It’s useful for tasks like adding new features and writing patches. The default Git branch is named main or master:

$ git branch
*master
dev

We commit the local changes to the local branch of the repository, which in turn can be pushed to the upstream:

$ git push

Upstream is the remote repository. We push the changes for merging with the remote repository. That way, other developers can pull the remote repository once in a while to synchronize the changes:

$ git pull

In the next section, we’ll cover GitHub.

3. GitHub

GitHub is a platform that is primarily used for hosting Git repositories. So, in essence, GitHub provides a way to access code repositories from anywhere. It’s built around Git, which provides other extra features that help with software development.

In addition, it provides collaboration features like pull requests and reviews, GitHub Actions for automating workflows, and hosting for various package types like npm, NuGet, Maven, and others. GitHub also provides a social coding platform, where we follow projects, star, and fork other repositories.

On top of that, it also provides management features like issues, milestones, and project boards as well as documentation via GitHub Pages and GitHub Wikis.

GitHub provides a web client, mobile applications, and an official desktop application. However, other alternative clients work very well with GitHub, including SourceTree, GitKraken, and Fork.

The following table outlines the differences between Git and GitHub

Feature

Git

GitHub

Type

DVCS

Platform for hosting Git repositories

Location

Local

Remote

Collaboration

Basic (Git commands)

Advanced (pull requests, reviews)

UI

Command-line

Web UI, mobile apps, desktop app

Project Management

None

Included

Automation

Basic (via Hooks)

GitHub Actions

Community Features

None

Included

Security

Basic

Enhanced

4. Conclusion

In this article, we outlined the differences between Git and GitHub. We learned what a VCS is and the two types of VCS. Then, we covered how Git is a completely different standalone tool that can exist without GitHub.

Finally, we discussed the GitHub platform, which provides a way to host and manage Git repositories.