Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,4 @@ Patches and Suggestions
- Étienne BERSAC
- ☃ pitr
- 单元源
- Don 'duckunix' Harper
12 changes: 7 additions & 5 deletions bin/git-fork
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ test -z "$url" && abort "github repo needs to be specified as an argument"
echo "Enter your github username"
read user
[ -n "$user" ] || abort "git username required"
echo "Enter github password for user \"$user\""
read -s passwd
echo "Enter github two-factor authentication code (leave blank if not set up)"
read MFA_CODE
# personal access token
# config name is github-personal-access-token '_' is not allowed in git config

github_personal_access_token=$(git config git-extras.github-personal-access-token)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay...updated.


test -z "$github_personal_access_token" && abort "git config git-extras.github-personal-access-token required"

# extract owner + project from repo url
project=${url##*/}
Expand All @@ -35,7 +37,7 @@ fi
# create fork
curl -qsf \
-X POST \
-u "$user:$passwd" \
-u "$user:$github_personal_access_token" \
-H "X-GitHub-OTP: $MFA_CODE" \
"https://api.github.com/repos/$owner/$project/forks"

Expand Down
14 changes: 14 additions & 0 deletions man/git-fork.1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ adds the forked repo as a remote called \fBorigin\fR
.P
Remotes will use ssh if you have it configured with GitHub, if not, https will be used\.
.
Create a fork a project on GitHub via command line\.
.
.P
A personal access token is required for making the API call to create a new fork in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/repos#forks\fR
.
.P
Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s)
.
.P
Use \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token <your\-personal\-access\-token>\fR
.
.P
If using multiple accounts, override the global value in the specific repo using \fBgit config git\-extras\.github\-personal\-access\-token <other\-acc\-personal\-access\-token>\fR
.
.SH "EXAMPLE"
Fork expect\.js:
.
Expand Down
10 changes: 10 additions & 0 deletions man/git-fork.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/git-fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ git-fork(1) -- Fork a repo on github

Remotes will use ssh if you have it configured with GitHub, if not, https will be used.

Create a fork of a project on GitHub via command line.

A personal access token is required for making the API call to create a fork in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/repos#forks)

Make sure the personal access token has the right `OAuth` scopes for the repo(s)

Use `git config --global --add git-extras.github-personal-access-token <your-personal-access-token>`

If using multiple accounts, override the global value in the specific repo using `git config git-extras.github-personal-access-token <other-acc-personal-access-token>`

## EXAMPLE

Fork expect.js:
Expand Down