1

this is what i got when tried using it in cmd line


git: 'fork' is not a git command. See 'git --help'.

The most similar command is fsck

  • `fork` is not a command. To make a new branch, use `git branch`. To create a new repo, use `git clone`. To make a fork, use `git clone` to make a new repo, and then call the new repo a fork. – William Pursell Jan 05 '21 at 14:15

2 Answers2

4

A Fork is a GitHub operation, not a Git one.

You can use the GitHub CLI gh fork command to make a fork.

Example:

# 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$

That way, you don't have to clone any repository: the forked repository is created and then cloned for you.

This is different from creating a branch inside your own repository.


See also gh repo fork -- fork-name=xxx with gh 2.5.0 (Feb. 2022)

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
1

Use hub command line tool that was specifically designed to work with Github. Install it or download it and add it to your PATH and then do:

alias git=hub

You can now do git fork to fork the repository you're currently in. hub also comes with other useful commands, for example you can do git pull-request to send a pull request in the command line (do not confuse it with git-request-pull which is the built-in Git command)

Arkadiusz Drabczyk
  • 10,250
  • 2
  • 20
  • 35