Data report"State of code review 2024" is now liveRead the full report

How to checkout a repository from GitHub

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Checking out a repository from GitHub involves copying the repository from GitHub to your local machine, allowing you to work on the project offline and sync changes when necessary. This guide will walk you through the steps to successfully checkout a repository from GitHub.

In Git terminology, "checking out" a repository often means switching between different branches or commits. However, in the context of this guide, we are focusing on how to clone a repository from GitHub to your local machine, which is often informally referred to as "checking out a repository."

Before you can checkout the repository, you need to locate it on GitHub. Go to the GitHub website and find the repository you want to work with by searching or browsing. Once you’ve found the repository, navigate to its main page.

On the repository's page on GitHub, locate the "Code" button. Click on this button, and a dropdown menu will appear with a URL and options to clone the repository using HTTPS, SSH, or GitHub CLI. Copy the URL you prefer:

  • HTTPS: If you choose HTTPS, you can start using the repository without setting up additional SSH keys. It's simpler and more straightforward, especially for beginners.
  • SSH: If you choose SSH, you must have an SSH key set up on your machine and linked to your GitHub account. This method is more secure but requires additional configuration.

For more information on the differences between the two, see Git Clone SSH vs HTTPS.

Open your terminal or command prompt. Navigate to the directory where you want to store the repository and run the following command:

Terminal
git clone <repository-url>

Replace <repository-url> with the URL you copied from GitHub. This command creates a local copy of the repository on your machine.

After cloning, you will have a new directory named after the repository. Navigate into the cloned directory to ensure all files and the repository structure were copied correctly:

Terminal
cd <repository-name>
git status

This command shows the current status of the repository and confirms that you are now working in a Git-managed directory.

Once you have the repository on your local machine, you can start exploring its contents. Use standard Git commands to check existing branches, previous commits, and other details:

Terminal
git branch -a # List all branches
git log # Show commit history

For more information see the official Git documentation.

Git gud
"It's the first Git workflow I've used that actually feels good."
–@robboclancy
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2