Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To clone a GitHub repository, open its page, select Code, copy an HTTPS or SSH URL, then run git clone <URL> in a terminal opened in the parent directory where you want the new folder. Cloning downloads the repository into a new local folder; it does not build, install, or test the project.

Clone a repository with Git

  1. Open the repository’s main page on GitHub and select Code.
  2. Choose HTTPS or SSH and copy the displayed URL. GitHub documents both as command-line cloning options: GitHub’s cloning instructions.
  3. Open a terminal in the directory that should contain the new repository folder. For example, if you want the folder inside projects, open the terminal in projects, not in the folder you expect Git to create.
  4. Run the command with the copied URL in place of the example:
    git clone https://github.com/OWNER/REPOSITORY.git
  5. Change into the new folder and check the checkout, for example with cd REPOSITORY followed by git status.

Git creates the new folder, initializes it as a repository, adds a remote named origin pointing to the source URL, downloads the repository files and commits, and checks out its default branch. The folder name normally comes from the repository name. The clone command itself does not install project dependencies or run the project.

Choose a cloning method

Method How to start Best fit
Git in a terminal git clone <URL> You want the standard Git command and control over the URL and destination.
GitHub CLI gh repo clone OWNER/REPO or use a GitHub URL You already use GitHub CLI for repository tasks.
GitHub Desktop On the repository page, open Code, choose Open with GitHub Desktop, then follow the prompts. You prefer a graphical workflow.

GitHub documents the CLI and Desktop options alongside terminal cloning in its cloning guide. No method is universally best; use the one that fits your existing workflow.

HTTPS or SSH: which URL should you use?

The URL you choose determines how Git authenticates. HTTPS is often the straightforward choice if you have not configured SSH keys. GitHub says HTTPS clone URLs are available regardless of repository visibility and can work behind a firewall or proxy. For a private repository, you still need permission to access it; the URL alone is not authorization.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With HTTPS, GitHub may prompt for credentials. When prompted for a password, use a personal access token rather than your GitHub account password, or use a credential helper such as Git Credential Manager. With SSH, you need an SSH key pair and must add the public key to your GitHub account. Organization single sign-on (SSO) rules may require extra authorization for either credential method. See GitHub’s documentation for authentication to GitHub and connecting with SSH.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix common clone problems

“Repository not found” or access denied

For a private repository, confirm that your GitHub account has access and that the credentials used by Git belong to that account. If the organization uses SSO, check whether the credential must be authorized for the organization. A correct clone URL cannot bypass repository permissions.

Authentication fails with an HTTPS URL

When Git requests a password for an HTTPS operation, provide a personal access token or configure a supported credential helper. GitHub account passwords are not accepted for Git authentication over HTTPS. Review GitHub’s authentication documentation for current credential options.

SSH connection times out or port 22 is blocked

If your network blocks SSH on port 22, GitHub documents connecting over HTTPS port 443 using ssh.github.com. This option is not supported for GitHub Enterprise Server or GitHub Enterprise Cloud with data residency. Follow the applicable SSH over the HTTPS port instructions before changing SSH settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Git is not recognized or the command is missing

The cloning steps assume Git is installed and available in your terminal. Installation steps depend on your operating system; use the instructions for your OS before retrying git clone.

What to check after cloning

  • The new folder appears in the directory where you ran the command.
  • git status reports the checkout state from inside that folder.
  • The repository’s files are present, but any separate setup, build, or test instructions still need to be followed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.