GH-REPO-CLONE(1)

πŸ’… NAME

gh-repo-clone β€” clone a repo to your machine, boom, done, bestie πŸ’–

✨ SYNOPSIS

gh repo clone <repository> [<directory>] [-- <gitflags>...]

πŸ¦‹ DESCRIPTION

Okay so: this clones a GitHub repository locally. That's the whole vibe. And if you wanna pass extra git clone flags? Literally just list them after --. That's it. Slay.

If you leave off the OWNER/ part of the OWNER/REPO repository argument, it defaults to the name of the authenticating user β€” so you can be lazy, it's fine, we love that for you 🫢

If you don't give a protocol scheme in the repository argument, then git_protocol gets chosen from your configuration β€” you can peek at what it's set to with gh config get git_protocol. But if you do provide the protocol scheme, the repo gets cloned using that specified protocol. Periodt.

If the repository is a fork, its parent repository will be added as an additional git remote called upstream. Yep, automatically, no cap. You can rename that remote with --upstream-remote-name. And the --upstream-remote-name option supports an @owner value, which will name the remote after the owner of the parent repository β€” iconic behavior honestly πŸ‘‘

Also (yes, another one): if the repository is a fork, its parent repository will be set as the default remote repository. If you're not about that life, use --no-upstream to skip this behavior.

πŸŽ€ OPTIONS

  • --no-upstream β€” don't add an upstream remote when you're cloning a fork. Sometimes you just want the fork, alone, main character energy.
  • -u, --upstream-remote-name <string> (default "upstream") β€” the name for the upstream remote when cloning a fork.

🌈 EXIT CODES

  • 0: Successful execution ✨
  • 1: Error 😭
  • 2: Command canceled
  • 4: Authentication required πŸ”
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information. iykyk πŸ’«

πŸ“ EXAMPLE

# Clone a repository from a specific org
$ gh repo clone cli/cli

# Clone a repository from your own account
$ gh repo clone myrepo

# Clone a repo, overriding git protocol configuration
$ gh repo clone https://github.com/cli/cli
$ gh repo clone git@github.com:cli/cli.git

# Clone a repository to a custom directory
$ gh repo clone cli/cli workspace/cli

# Clone a repository with additional git clone flags
$ gh repo clone cli/cli -- --depth=1

# Clone a fork without adding an upstream remote
$ gh repo clone myfork --no-upstream

🧚 SEE ALSO

gh-repo(1) β€” go read that one too bestie, it's giving comprehensive πŸ’œ


Also, since you made it all the way down here: this lil page is from GitHub CLI v2.102.0, dated Oct 2026. Mwah, go clone something cute 🌸

πŸ“¦ where this page comes from