As an aspiring web developer, you may already be familiar with GitHub as an application you can use to store your code on the web.
But it’s also so much more than that. So, what is GitHub?
Essentially it’s a tool used by individual developers and teams alike all across the world to collaborate with each other on virtually any kind of project imaginable.
GitHub uses a piece of version control software (more on this later) called “Git”, which you can download and use on your local development machine. Git is a separate piece of software from GitHub, and this article assumes you are somewhat familiar with the concept of Git. If not, check out our explanation of the differences between Git and GitHub.
Github has many unique features that make it extremely popular these days. Besides simple storage, it’s an entire ecosystem complete with an elaborate social networking aspect, allowing individual developers to contribute to multiple teams and projects. Once you get into the flow of managing repositories using GitHub, you’ll get an idea of just how useful it can be.
In this guide, I’ll show you what GitHub is and provide some useful tips on how to use GitHub. This article will be split into the following sections:
- What is version control?
- A Git refresher
- What is GitHub: Main functions and features
- GitHub: Wrapping up
1. What is version control?
Version control is, as the name implies, a way to manage different versions of your code base.
We’ve written a complete guide to version control systems in web development if you’re interested in learning more, but we’ll do a quick introduction here. Firstly, let’s start by asking the question “Why would you have different versions of the same code?”
Think about when you’re playing a video game. You are about to enter a difficult dungeon from which you can’t escape until you beat the boss. Before entering the dungeon, you’ll want to save your game just in case the boss turns out to be too hard to beat and you’re stuck in the dungeon forever. If the boss turns out to be too hard, all you have to do is load the version of your game where you were outside the dungeon and you’re free to go off and level up.
However, when you enter the dungeon and begin to progress, you’ll want to save your game along the way, but you don’t want to overwrite the original game you saved outside the dungeon. So when you save your game from inside the dungeon, you create a completely new branch, basically a copy, of your original game.
If you successfully make it through the dungeon, then your current saved version becomes your new main version, and you continue on through the game. This is very similar to version control with Git and GitHub.
A vital tool for teams of developers
Let’s say you have an application you’re working on with a team, and you get tasked with adding a special feature to it.
Instead of building the feature on the main branch (which could potentially bring down the entire application if you accidentally break something), you make a “copy” of the application and begin building the feature on that copy.
When you’re done developing the feature, you ask your teammates to review your code. If you get the “Okay” from them, you can safely “merge” your special feature branch back into the main branch.
When you have multiple developers working on the same application, sometimes multiple developers will be working on the same exact file. This can create problems when merging the files back together, because it’s unknown which version of the files is the correct one. When this happens (and it does happen, unfortunately), a good version control system helps to make the solution relatively painless.
This is how Git and GitHub work for version control. They are used so that multiple people can work on multiple files and multiple features in the same application and avoid major issues due to conflicting code or different versions on each developer’s local machine.
2. A Git refresher
Before we can get down to what is GitHub, it’s important to refresh ourselves on Git itself. Essentially, Git is a piece of version control software you can download and use on your machine.
You use it to basically take snapshots (“commits”) of your file structure when you get it to a state you want to “save” (eg. after building a new feature, after fixing a bug, after adding third party software, etc).
You can use Git to create branches (as explained above), resolve conflicts with different versions of files, and integrate with GitHub so that your snapshots (commits) can be pushed up for your team (or the world) to see. If you’d like to learn more about how to go about doing this, check out our guide to using the git commit command.
This is typically done via the command line, or you can do it via a Graphical User Interface (or “GUI”, for short). However, it’s widely expected that you’re able to navigate Git on the command line, so if you’re interested in adding this essential tool to your skillset, you might as well dive right in with that!
3. What is GitHub: Main functions and features
So, now that we’ve brushed up on version control and Git, what is GitHub?
It’s a key element of how a web developer typically works. You may use it for something as simple as free cloud storage for your projects, or you may use it to show your code to potential employers interested in assessing your coding skills.
As you can see, it’s far more than just a place to keep code safe in the cloud. It’s a tool used by both local and distributed teams collaborating on projects. Keep in mind, projects are not necessarily limited to software!
Repositories (or “repos” for short) can be created by anyone. A single repo is usually used for a single project.
GitHub repos are, by default, open to the public. If users don’t want the public to be able to access their repos, they can choose to keep their projects private for a small fee. In this case, the owner of the repo has control over who can view or copy the code.
Public repositories, on the other hand, can be seen and copied by anyone. However, for someone to be able to make changes to the original codebase, the repo’s administrator must first approve it.
So don’t worry—no one can change your repository projects unless you give them special permission!
When someone wants to make changes to a GitHub repository, the person (usually a member of the team) will create a separate “branch”.
This branch is simply a copy of the current version—well, it’s not actually a copy—Git’s method of storing files is more efficient than that, but we can think of it as a copy. In most cases the current version is referred to as the “master branch”.
The developer will work on the feature in this new branch until the feature is complete. At that time, the developer will “commit” (store a snapshot of) the code in the new branch and then they will create a “pull request”. This basically lets the rest of the team know that the feature is finished and ready to be code-reviewed and, finally, merged into the main branch.
Team members can review the new code (another good way to ensure good code quality) and then the administrator can approve the merge. The code will then be merged into the main branch, and the feature branch can be deleted. This is all done using GitHub!
The GitHub social network
Because GitHub is so collaborative by nature, it shouldn’t be a surprise that another main feature is its significant social networking aspect.
Users can upload pictures and biographies, they can follow other users and “favorite” their projects, and of course, form teams, or “organizations”, whose leaders can exert very specific control over the access of the individual members collaborating on a project.
This is an example of a single user’s “home page”—there’s a list of repositories and the number of followers/users followed. At the bottom there is even a display of the number and frequency of contributions over the last year to repositories to which the user has access.
It’s very much like the home page of other social networks—except that it’s for coding!
4. Final thoughts
So there you have it: A beginner’s introduction to what is GitHub.
Whether you are working on personal projects alone or are part of a team working on huge enterprise software, GitHub is a useful tool. If you’re alone, you can use it to store your code and show off what you’ve done to others.
You can use it to look at others’ projects for inspiration and even fork (copy) projects that you may like to expand on and either contribute to, or break off and start building your own project.
In teams, it not only helps to simplify the complexity of multiple developers working on multiple files at the same time, but it also aids collaboration—reducing conflicts and improving code quality.
Many companies use GitHub for many reasons, so becoming familiar with it is absolutely essential. So as well as not just saving you from embarrassing yourself by asking “What is GitHub?”, it’s a very desirable skill to add to your web developer skillset!
Want to learn more about GitHub and how to use it?
- GitHub themselves have a great tutorial that will teach you the basic flow of creating a repository, managing branches, making changes, and merging those changes via pull request.
- Developer Peter Cottle created a fantastic activity that helps more visual learners learn about branching with Git. The first four activities in the “Introduction Sequence” give users practice in committing (making a “snapshot”), branching, and merging, as well as another important topic not covered in this article: “rebasing”.
- Another great explanation of Git that goes very in-depth (from a competitor of GitHub)
- An excellent explanation of general version control brought to you by Atlassian, owner of BitBucket.