GIT-FORK(1)

πŸ’– GIT-FORK(1) β€” or, how to stealβ€” no wait, fork πŸ’–

okay bestie, sit down, hydrate, because we're talking about git-fork from the Git Extras collection and it's genuinely one of my faves. manual section 1, main character energy, no cap. πŸ“


✨ NAME ✨

git-fork β€” Fork a repo on github 🍴


🌸 SYNOPSIS 🌸

git-fork [<github-repo-url>]

that's it. one optional lil argument. we love a minimal interface. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea. If a github repo url is given, fork the repo. it's like clone but it forks first. so unserious of it but also so iconic.

  1. forks the repo on github
  2. clones the repo into the current dir
  3. adds the original repo as a remote called upstream

and if a url is not given and the current dir is a github repo, fork the repo. yes queen, it just figures it out from where you're standing.

  1. forks the current repo
  2. rename the origin remote repo to upstream
  3. adds the forked repo as a remote called origin

now, about the remotes: Remotes will use ssh if you have it configured with GitHub, if not, https will be used. so if you've done the ssh key setup, you get the pretty version. if not, it still works, don't stress. 🫢

tl;dr β€” Create a fork of a project on GitHub via command line. that's the whole vibe.

⚠️ okay important, do NOT skip this: A personal access token is required for making the API call to create a fork in GitHub. like, required required. no token, no fork, it's giving locked door.

API Documentation here https://docs.github.com/en/rest/reference/repos#forks πŸ”₯

also!! Make sure the personal access token has the right OAuth scopes for the repo(s). a token with the wrong scopes is just a decorative little string, bestie. 😭

okay so how do you feed it the token:

  • Use the GITHUB_TOKEN environment variable, or
  • run git config --global --add git-extras.github-personal-access-token <your-personal-access-token>

and if you're out here living that multiple accounts life (we see you, alt era πŸ‘‘), override the global value in the specific repo using:

git config git-extras.github-personal-access-token <other-acc-personal-access-token>

per-repo override. genius. obsessed. 🌈


πŸŽ€ EXAMPLE πŸŽ€

Fork expect.js:

$ git fork https://github.com/LearnBoost/expect.js

or just:

$ git fork LearnBoost/expect.js

Then:

$ ..<forks into your github profile and clones repo locally to expect.js dir>...

$ cd expect.js && git remote -v

  origin          git@github.com:<user>/expect.js (fetch)
  origin          git@github.com:<user>/expect.js (push)
  upstream        git@github.com:LearnBoost/expect.js (fetch)
  upstream        git@github.com:LearnBoost/expect.js (push)

look at those remotes. origin is you, upstream is them. so clean, so organized, a whole system πŸ’…

and If the current dir is a clone of expect.js, this has the same effect:

$ git fork

no args, no url, just vibes. it knows. ✨


πŸ’œ AUTHOR πŸ’œ

Written by Andrew Griffiths <mail@andrewgriffithsonline.com> β€” thank you king, this tool ate πŸ™Œ


😭 REPORTING BUGS 😭

found a bug?? not me manifesting it, but if you did:

https://github.com/tj/git-extras/issues

go tell them, they're nice about it fr fr 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

https://github.com/tj/git-extras

the whole Git Extras cinematic universe lives there. go explore. iykyk 🌟


later bestie β€” this was GIT-FORK(1) from Git Extras, dated May 2026. go fork something cute, stay hydrated, and remember your token scopes. mwah πŸ’‹

πŸ“¦ where this page comes from