gh repo fork

Create a fork of a repository

Synopsis

Create a fork of a repository.

With no argument, creates a fork of the current repository. Otherwise, forks the specified repository.

gh repo fork [<repository>] [flags]

Options

      --clone    Clone the fork {true|false}
      --remote   Add remote for fork {true|false}

Options inherited from parent commands

      --help   Show help for command

In use

With no arguments

Inside a git repository, and without any arguments, we will automatically create a fork on GitHub on your account for your current directory. It will then prompt if you want to set an upstream remote.

# Create a fork for the current repository.
~/Projects/cli$ gh repo fork
- Forking cli/cli...
 Created fork user/cli
? Would you like to add a remote for the fork? Yes
 Renamed origin remote to upstream
 Added remote origin
~/Projects/cli$

With arguments

If you pass a repository in OWNER/REPO format, `gh` will automatically create a fork on GitHub on your account and ask if you want to clone it. This works inside or outside of a git repository.

# Create a fork for another repository.
~/Projects$ gh repo fork cli/cli
- Forking cli/cli...
 Created fork cli/cli
? Would you like to clone the fork? Yes
Cloning into 'cli'...
 Cloned fork
~/Projects$ cd cli
~/Projects/cli$

Using flags

Use flags to skip prompts about adding a git remote for the fork, or about cloning the forked repository locally.

# Skipping remote prompts using flags
~/Projects/cli$ gh repo fork --remote=false
- Forking cli/cli...
 Created fork user/cli
~/Projects/cli$
# Skipping clone prompts using flags
~/Projects$ gh repo fork cli/cli --clone=false
- Forking cli/cli...
 Created fork user/cli
~/Projects$