>_ ghcli.com
ghcli / Repositories / gh repo clone

gh repo clone

Clone with shorthand, no full URL

gh repo clone clones a repository using simple owner/name shorthand instead of a full URL, and uses your existing GitHub authentication automatically. For forks it also wires up the upstream remote so you can pull in changes from the original project.

Quick answer
gh repo clone cli/cli

Syntax

gh repo clone <repository> [<directory>] [-- <git-clone-flags>]

Examples

Clone by owner/name shorthand

gh repo clone cli/cli

Clone into a specific folder

gh repo clone cli/cli my-cli

Clone one of your own repos (owner optional)

gh repo clone my-project

Shallow clone by passing git flags after --

gh repo clone cli/cli -- --depth=1

Options & flags

FlagWhat it does
-u, --upstream-remote-nameName for the upstream remote when cloning a fork (default "upstream").
-- <git flags>Everything after -- is passed straight to git clone (e.g. --depth, --branch).

How to use gh repo clone, step by step

  1. Make sure you are signed in with gh auth status.
  2. Run gh repo clone owner/name.
  3. gh clones over HTTPS or SSH based on your git config, using your token.
  4. If it's a fork, gh adds an upstream remote pointing at the parent.

Common errors and fixes

could not resolve to a Repository with the name 'owner/name'

Check the spelling and that you have access. For private repos, confirm your token has the right scopes via gh auth status.

git: 'credential-manager' is not a git command

A credential helper is misconfigured. Run gh auth setup-git to let gh manage git authentication.

Related commands

Frequently asked questions

How do I clone a repo with GitHub CLI?

Run gh repo clone owner/name — for example gh repo clone cli/cli. You don't need the full URL, and gh uses your existing authentication so private repos just work.

Can I pass git flags like --depth to gh repo clone?

Yes. Add them after a double dash: gh repo clone cli/cli -- --depth=1. Everything after -- goes straight to git clone.

Does gh repo clone set up the upstream remote for forks?

Yes. When you clone a fork, gh automatically adds an upstream remote pointing at the original repository so you can sync later.