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.
gh repo clone cli/cliSyntax
gh repo clone <repository> [<directory>] [-- <git-clone-flags>]Examples
Clone by owner/name shorthand
gh repo clone cli/cliClone into a specific folder
gh repo clone cli/cli my-cliClone one of your own repos (owner optional)
gh repo clone my-projectShallow clone by passing git flags after --
gh repo clone cli/cli -- --depth=1Options & flags
| Flag | What it does |
|---|---|
| -u, --upstream-remote-name | Name 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
- Make sure you are signed in with
gh auth status. - Run
gh repo clone owner/name. - gh clones over HTTPS or SSH based on your git config, using your token.
- If it's a fork, gh adds an
upstreamremote 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.