GH-REPO-FORK(1)

🍴 gh-repo-fork β€” the GitHub CLI manual, bestie edition

okay so this is gh-repo-fork, from the GitHub CLI manual (that's the <kbd>1</kbd> situation, it's a command page πŸ’…). It's the one that makes you a whole fork of a repo, and honestly? iconic behavior. Let's get into it.


✨ SYNOPSIS ✨

gh repo fork [<repository>] [-- <gitflags>...] [flags]

Like, that's the whole shape of it: optional repo name, optional extra git flags after a --, and then your flags. Slay.


πŸ’– DESCRIPTION πŸ’–

Create a fork of a repository. Simple as that, no cap.

  • Give it no argument and it creates a fork of the current repository β€” like, the one you're standing in. main character energy.
  • Give it a <repository> and it forks that specified repository instead.

By default, the new fork gets set as your origin remote, and any existing origin remote gets renamed to upstream. Yeah, it just does a little rename behind your back (lovingly). If you're not about that life, you can set a name for the new fork's remote with --remote-name.

The upstream remote will be set as the default remote repository. periodt.

And if you're feeling extra, additional git clone flags can be passed after --. 🫢


πŸŽ€ OPTIONS πŸŽ€

  • --clone β€” Clone the fork. Like, actually grab it locally.
  • --default-branch-only β€” Only include the default branch in the fork. Keep it minimal, keep it cute.
  • --fork-name <string> β€” Rename the forked repository. Glow-up for your fork's name.
  • --org <string> β€” Create the fork in an organization.
  • --remote β€” Add a git remote for the fork.
  • --remote-name <string> (default "origin") β€” Specify the name for the new remote.

πŸ”₯ EXIT CODES πŸ”₯

okay bestie, here's your vibe check on how this thing bounces:

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

🌸 EXAMPLE 🌸

# Fork a repository
$ gh repo fork owner/repo

# Fork a repository and clone it locally
$ gh repo fork owner/repo --clone

# Fork a repository without cloning it, skip the prompt
$ gh repo fork owner/repo --clone=false

See that last one? --clone=false is the sneaky little "no thank you, don't ask me" move. obsessed. πŸ¦‹


πŸ‘‘ SEE ALSO πŸ‘‘

  • gh-repo(1) β€” the rest of the repo family, go say hi

okay that's the whole page, mwah πŸ’– β€” this lil masterpiece is GitHub CLI v2.102.0, dated Oct 2026, and it's the GH-REPO-FORK(1) page so you know exactly where you are. go forth and fork responsibly, bestie 🌈⭐

πŸ“¦ where this page comes from