Summary
- GitHub is a platform for hosting and sharing code, with free web hosting and social media features.
- Git is a version control system that tracks code changes and is used to drive GitHub.
- Other Git hosts—like GitLab and Bitbucket—are available, but GitHub is by far the most popular.
GitHub has become so ubiquitous that you might think Git is an interchangeable shorthand. But the two are very different, and alternatives to each are available, if not quite as popular.
What Is GitHub?
GitHub is a web app that lets developers host, share, and contribute code for software. Many of these projects are open source and invite contributions from the public. GitHub has a community focus with user accounts, pull requests to manage code changes, issue trackers, and wikis for documentation.
The site launched as an independent product in 2008, before Microsoft bought it in 2018. Since its launch, GitHub has grown in popularity to such an extent that it is now the de facto home for many popular apps.
The GitHub Pages feature offers free web hosting for projects, so they can be completely self-contained on the platform, without the need for a separate website. You can even perform limited edits directly on GitHub. Depending on the nature of your project, you can also clone a repository to edit and test the code locally.
The GitHub web service uses Git as an underlying technology to track its projects.
So, What Is Git?
Git—a distributed version control system (VCS)—launched in 2005, and was developed by Linux kernel creator, Linus Torvalds. Git is open-source software that tracks code changes over time. It stores the differences between versions of each file, so it’s like having an unlimited number of saved versions. Git uses the term “repository” to refer to a collection of files that make up a project.
Developers normally use Git on the command line via the git command. This program has a huge number of options, with a vast array of sub-commands to perform various low-level functions on a Git repository.
For example, you can turn a normal directory of files into a Git repository using this command:
git init
A typical workflow involves editing files, and then committing changes to Git to save a version of each file:
git add file-to-track.cgit commit -m "Fixed a bug with the checkout process"
You can clone a GitHub project, work on it locally, and push your changes to the remote repository on GitHub’s servers. You can do so using the same mechanism for any Git repository, whether it’s hosted on GitHub, a similar competing service, or a local server.
If you’re uncomfortable using the git command in a terminal, you can use a GUI Git client instead. The GitHub Desktop app works with any Git repository, but it works well with the GitHub service by default.
Other Git clients are available, including Fork, Sourcetree, and GitKraken. You can use them with a GitHub project or any other Git repository. Switching clients is easy, so feel free to experiment to find one you like.
Do I Have to Use Both—or Either?
First, you should understand that you can use GitHub to download software without a user account. Most projects let you download an executable app via the Releases page and you can always clone a public repository to obtain a complete copy of its source code.
If you’re looking to maintain a public open-source project, GitHub is an excellent place to host it, but it’s not the only option. Aside from managing your project manually, you can use alternative hosts like GitLab or Bitbucket. These services do more-or-less the same thing as GitHub.
Because these services are built on top of Git, moving your repository to a different host—or using more than one—is fairly straightforward. This means you can always move your source code, but the features that GitHub adds on top of Git—issues or wiki pages, for example—are tied to the service. Therefore, you might choose to minimize your use of these features to avoid locking yourself into GitHub.
However, GitHub’s API is comprehensive, so your data is freely obtainable—with a bit of work. You can access issues using the API and download their associated data to migrate issue-tracking to a different platform. Project Wikis are themselves Git repositories, so you can clone them and export them if necessary.
If you want to use a different VCS, you’ll need to look further afield than GitHub. Beanstalk is a web app that supports both Git and one of its alternatives, Subversion (SVN).
There are other alternatives to Git, like Mercurial. However, these are far less popular than Git, and are only really worth using if you require some specific niche features. For most projects, especially new ones, Git should be your default VCS, and GitHub’s excellent support for it will only reinforce your choice.