GitHub is an online service that you can use to host the code for your projects and carefully control additions, changes, and adjustments. GitHub allows other people to collaborate on your projects while providing the tools for you to carefully control or limit those contributions. The platform also gives you easy access to version history, and the ability to roll back changes.
The backbone of GitHub is a version control technology called Git. With Git, you have a code repository that your project lives in, and you make incremental additions called commits, with the ability to roll back as necessary to previous commits. Additionally, Git allows for branching, which is useful for working on different parts of a project separately.
GitHub harnesses the power of Git combined with a software-as-a-service (SaaS) web model: It's one of the most-used web platforms for collaborating on development projects and one of the best Git repository hosting services.
In this tutorial, we'll walk through how to use GitHub, learning how to contribute to other people's projects as well as how to create and manage your own.
GitHub Pricing: GitHub is free to use, with unlimited public and private projects. Free accounts only allow three collaborators on private projects. A Developer Pro account for $7/month allows unlimited collaborators as well as advanced tracking tools and insight graphs about contributions and contributors to your projects.
Connect GitHub to 1,500+ other apps with Zapier's GitHub integrations.
Glossary of GitHub Terms
Git: Git is a version control system that allows for the sharing of an entire codebase among collaborators and for the developers on a project to create, label, and refer to small batches of changes.
Repository: In Git, a repository is the
./git
folder, which stores a history of all of the changes to the files in your project. In GitHub, the term is broader, and includes your project (including the./git
folder) and all of its files and directories.Branch: A branch is a pointer to a commit. In layman's terms, a branch of a repository provides a separate copy of the codebase, where you can, for example, develop a particular feature in isolation before merging it, incrementing the codebase for use by others when complete.
Commit: Git commit is a command that saves changes to the codebase with a descriptive message. Each commit is typically a small subset of changes.
Issue: You, or one of your repository's users, create an issue when you find a problem with the code in the repository. Issues can also be a way to keep track of tasks to accomplish.
Pull Request: A pull request occurs when a contributor makes changes in a branch and then wants to merge it back into the master branch. The pull request allows for comparison of the changes between two branches, for the resolution of conflicts, and for others to review and approve the changes before the reviewers merge them.
How to Set Up Your GitHub Account
Once you've signed up for a GitHub account, take a quick look around your profile and settings. To start, click the dropdown menu in the top right corner and select Settings.
Here are a few things that you might want to take care of before you start working on the platform:
The first tab is the Profile section. This is basic public profile info: a display name, short bio, image, and other such fields.
The Account and Security sections contain your username and password change settings as well as setup for two-factor authentication.
Notifications is an important one to check, as GitHub has the ability to send you a lot of notifications, and you might want to pare those down by default.
The Billing section is where you can purchase and manage subscriptions for paid plans.
SSH and GPG Keys is an important one if you are using Git on your command line (or using a program like GitKraken or Tower) to access your GitHub repository.
How to Search on GitHub
GitHub's search functionality allows you to do two distinct things:
Search across the platform for information in any public repository (or private ones you have access to)
Search for details within a chosen repository
When you start typing in the search bar, a dropdown menu gives you the option to search in the current repository or all of GitHub. It also gives you options of other repositories of yours and task boards to search.
When searching the GitHub platform, you can use filters to search only for (or exclude) issues or PRs tagged with specific labels. Pro tip: Many repositories have labels called help wanted
or good first issue
. People who wish to collaborate search for these labels to find issues to take on. You can also filter by the result type (PR vs. issue vs. code), by the status of a PR, by author, and more.
For more information on search modifiers you can use when searching on GitHub, take a look at the GitHub documentation.
How to Contribute to Projects in GitHub
The more you do on GitHub, the stronger your profile becomes—in addition to the practical experience you acquire while doing work on open source projects.
While searching for projects to contribute to, one of the first things you should do is inspect READMEs. The README.md is typically the first file created in a repository, with the purpose of being an introduction and sometimes an index, so it gives you a quick sense for what a repository is for. The README is right there when you open a repository, just below the file list.
Often, there's also a CONTRIBUTING.md guide, another file that details the process of contributing to the repository. This can include important style or process information, so if there is one, be sure to check it out: Some projects will not accept pull requests and contributions if the code doesn't follow their style guide, or if it doesn't contain the appropriate tests.
Once you've identified a repository you'd like to contribute to, take a look through the list of issues on the repository and decide what you'd like to take on. The issues list is in the top bar of the repository.
Well-maintained projects will have a variety of labels for issue types, priorities, and even levels of expertise or familiarity required to complete them. Be sure to look through the comments on an issue to obtain more information on the problem and its potential solutions, as well as to find out if anyone else has made any progress on it.
When working on a file, you can use the GitHub web editor to make changes. From the repository, click on a file, and then click the edit icon in the top right corner of that file.
This opens the editor, where you can make changes to the file's contents. When done, there are options at the bottom for choosing which user information to add to the commits (if you have more than one set up), and whether to commit straight to the master branch or to another existing or new branch.
The Preview changes tab at the top allows you to see your Markdown rendered in the same way anyone who views the file on the web will see it. In the top right are settings for tabs. You select what type of spacing you want tabs to use, how many spaces wide they are, and whether you want to have a word wrap on.
On your profile page, there's a chart of your contribution activity. When working on your GitHub profile with the goal of getting development jobs, the more activity in your chart the better. You can set your chart to show private repository contributions as well: It won't show the details of your committed code or messages, but the chart of contributions will show that you've worked on projects during that time.
How to Create a Repository in GitHub
Creating a repository is as simple as going to Repositories and clicking New in the dashboard.
GitHub doesn't require unique repository names across all of GitHub since each repository has a namespace (your GitHub username), so just name it something short that directly pertains to the purpose of the repository. You can mark it public or private, and go ahead and initialize it with a README.
Once that's done, you'll see that the repository has several tabs along the top. In the Features section of the settings, you can enable or disable various features of a repository:
Issues
You (or other contributors) create issues in your repository to track all kinds of work: bugs, development tasks, user stories, and so on. To create an issue, click New and type a title; the labels on the issue indicate whether it requires a certain level of expertise or how urgent it is.
Project board
The project board allows for "lists of cards" style management of currently-in-focus issues, which optionally support a Kanban-style workflow. For simple workflows, this board can act as a replacement for something like Trello or the board views in a management tool like Jira, with the added advantage of being tied directly to issues.
Sponsorships
This is a newer feature allowing people to contribute to the project monetarily.
Project wiki
The GitHub project wiki is a no-frills, minimalist wiki that allows you to document your project. If enabled, it's an excellent place for a knowledge base or basic documentation, but it's no substitute for a standalone documentation site or a support portal for a larger and more complex project.
The Settings tab also has several other sections. One will give you options to manage contributors to your repository, which is especially important if the repository is private. The Webhooks section will allow you to set up webhooks to send information about repository events to outside services. There is also a tab to add notification email addresses for push events to the repository.
Connect your project to 1,500+ other apps using Zapier and webhooks.
The files within a repository have the same type of structure that a code project has in any file system. You can create directories or specific files, either in the web editor or locally on your computer and synced to the repository via Git. Creating a directory in the web editor just involves adding it before the name when naming a file (for example, newdirectory/newfile.md
).
How to Manage a Repository in GitHub
Managing a repository in GitHub involves a lot of moving parts: Pull requests are used to merge changes into the codebase, issues help you manage the tasks at hand and the bugs with your current code, and you can make changes in both the web editor and locally.
How to manage pull requests in GitHub
Pull requests are the tool by which you or your fellow contributors can do work on a repository. With Git, developers often work on features in isolated individual branches. After completing the work, the developer working on the branch merges it back into master, via pull request. When a contributor opens a pull request, you now have a place to easily compare the diff between the current master and the new changes. Contributors and reviewers chat inside the pull request about the changes and solve conflicts prior to merging the code changes.
The starting post in a pull request has a description that, in most cases, details a summary of what was changed in the pull request. The chain of comments below will read similarly to a forum conversation about this subset of changes.
The other important section here is the Files changed section at the top of the pull request. This is where the changed files can be seen, showing red lines of removed or modified code and green for the new lines. The reviewer can easily compare the two and then make comments based on the changes.
Labels can be added to a pull request, and you can also tag individuals as reviewers if you want a review from a specific collaborator.
How to manage local changes in GitHub
When working in your repository, you may find it useful to have a copy in a local environment, especially if you often make changes and additions to the repository. Read our guide for How to Push to GitHub for more information on that process.
How to manage releases in GitHub
Finally, there's also a section in your repository called Releases, where you can tag particular states in your repository as release versions. This allows the people using your software to download stable release copies of the project, or for you to mark particular milestones in your release calendar. Each release ties into a particular commit, so the codebase will be available to download in that state anytime from the Releases tab.
GitHub provides options for users who aren't pros at Git and version control to use the web interface to update code and work with pull requests. At the same time, it provides seasoned developers with a hosting and collaboration platform that will take input from any Git command line or Git program. Developers with code editors and development environments of all kinds contribute, and everyone keeps each other on the same page.
With its free private repositories, it's now in the same competitive market as other platforms for both larger teams and small shops. Developers who are looking for jobs can use their GitHub profile as a resume, and of course, the open source software (OSS) industry thrives here, allowing people to quickly find and work on projects that contribute to the broader community.