Skip to main content

GitHub flow

Follow GitHub flow to collaborate on projects.

Introduction

GitHub flow is a lightweight, branch-based workflow. The GitHub flow is useful for everyone, not just developers. For example, here at GitHub, we use GitHub flow for our site policy, documentation, and roadmap.

Prerequisites

To follow GitHub flow, you will need a GitHub account and a repository. For information on how to create an account, see "Signing up for GitHub." For information on how to create a repository, see "Create a repo." For information on how to find an existing repository to contribute to, see "Finding ways to contribute to open source on GitHub."

Following GitHub flow

Tip: You can complete all steps of GitHub flow through GitHub web interface, command line and GitHub CLI, or GitHub Desktop.

Create a branch

Create a branch in your repository. A short, descriptive branch name enables your collaborators to see ongoing work at a glance. For example, increase-test-timeout or add-code-of-conduct. For more information, see "Creating and deleting branches within your repository."

By creating a branch, you create a space to work without affecting the default branch. Additionally, you give collaborators a chance to review your work.

Make changes

On your branch, make any desired changes to the repository. For more information, see "Creating new files," "Editing files," "Renaming a file," "Moving a file to a new location," or "Deleting files in a repository."

Your branch is a safe place to make changes. If you make a mistake, you can revert your changes or push additional changes to fix the mistake. Your changes will not end up on the default branch until you merge your branch.

Commit and push your changes to your branch. Give each commit a descriptive message to help you and future contributors understand what changes the commit contains. For example, fix typo or increase rate limit.

Ideally, each commit contains an isolated, complete change. This makes it easy to revert your changes if you decide to take a different approach. For example, if you want to rename a variable and add some tests, put the variable rename in one commit and the tests in another commit. Later, if you want to keep the tests but revert the variable rename, you can revert the specific commit that contained the variable rename. If you put the variable rename and tests in the same commit or spread the variable rename across multiple commits, you would spend more effort reverting your changes.

By committing and pushing your changes, you back up your work to remote storage. This means that you can access your work from any device. It also means that your collaborators can see your work, answer questions, and make suggestions or contributions.

Continue to make, commit, and push changes to your branch until you are ready to ask for feedback.

Tip: Make a separate branch for each set of unrelated changes. This makes it easier for reviewers to give feedback. It also makes it easier for you and future collaborators to understand the changes and to revert or build on them. Additionally, if there is a delay in one set of changes, your other changes aren'