1.6.1 • Published 6 years ago

gfork v1.6.1

Weekly downloads
37
License
-
Repository
github
Last release
6 years ago

gfork

npm

Finds the GitHub repository of the NPM module, forks it under your account, and clones your forked repo.

$ gfork express
Forking "expressjs/express" -> "<you>/express"
Cloning into '~/gfork/express'
Running 'npm link' in '~/gfork/express'
Running 'npm link express' in <current-dir>

Installation

npm install -g gfork

Usage

gfork express

In its simplest form it:

  1. Finds the GitHub repository

  2. Clones it in ~/gfork/<repo>

  3. If it's an npm project, npm-links accordingly

Forking

If you let it authenticate to GitHub it can also fork the repo under your account.

Or you can pass your --username=xxx and --forked flag and it'll assume that you've forked on your own.

Forking a repo creates 2 sources in the cloned repo

  • origin - your fork
  • src - original repo

And 2 branches:

  • master - tracks origin
  • src - tracks src

This lets you push your changes to your own fork, and allows you to pull in latest changes from original repo easily as well:

git checkout src
git pull

Authentication

You can authenticate either via a token or your credentials (username/password/OTP).

*Note: GitHub is deprecating password authentication, in the future you may have no other option but to get the token manually.

Settings

Settings are stored as plain JSON in ~/gfork/config.json and you can edit or save new settings. Stored settings are applied on every use, and can be overridden by command-line arguments.

Commands

In addition to the default command, it has 2 extra commands (that works only on forked repos):

Use these commands in the cloned directory:

fetch

Fetch a PR from source remote. (E.g.: "git fetch src pull/42/head:#42")

E.g.:

gfork fetch 42

pr

Create a pull request on original source using your (current) branch

E.g.:

gfork pr

Inside a fork (~/gfork/express)

gfork fetch 42     # pulls http://github.com/expressjs/express/pull/42 as pull/42 branch
gfork pr           # opens http://github.com/expressjs/express/compare/<current-branch>

Detailed Usage

gfork <library> [directory]

Fork a library

Commands:
  gfork <library> [directory]     Fork a library  [default]
  gfork pr [branch=<current>]     Create a pull request on original source using your (current) branch
  gfork fetch <pull-request>      Fetch a PR from source remote. (E.g.: "git fetch src pull/42/head:#42")

Options:
  --help, -h          Show help  [boolean]
  --version           Show version number  [boolean]
  --library, -l       Library/URL to fork  [string]
  --directory         Directory to use for cloning'  [string] [default: "~/gfork/<repo>"]
  --clean             Remove everything in target dir before cloning  [boolean]
  --npmLink           Run 'npm link' in <directory> and 'npm link <repo>' in <cwd> respectively  [boolean] [default: "<true if npm-package>"]
  --command, -c       Command to execute after cloning inside the repo dir  [string]
  --cwdCommand, --cc  Command to execute in current-dir (cwd) (after --command exits cleanly)  [string]
  --token             GitHub token  [string]
  --tokenNote         Note to use when getting token  [string] [default: "Token for gfork"]
  --config            File(s) to save config and token for future  [array] [default: ["~/gfork/config.json",".gfork"]]
  --fork              Create a fork of the repo under your GitHub account  [boolean]
  --username          GitHub username (to fetch token, and to set for cloned git repo)  [string]
  --password          GitHub password (to fetch token)  [string]
  --otp               GitHub 2FA OTP (to fetch token)  [string]
  --email             Email to set for cloned git repo  [string]
  --skipAuth          Skip GitHub authentication (don't prompt)  [boolean]
  --setUser           Set username/email in forked git repo from GitHub account  [boolean]
  --remote, -r        Remote name to use for original library  [string] [default: "src"]
  --domain, -d        In case you use something like 'acc1.github.com' in your SSH config  [string] [default: "github.com"]
  --http              Use web url (https://) (instead of ssh/git)')  [boolean]
  --depth             Create shallow clone of that depth (applied to git command)  [number]
  --branch, -b        Local branch to use  [string] [default: "master"]
  --pullRequest       PR to fetch  [number]
  --cwd               Current working directory  [string] [default: "<cwd>"]
  --silent, -s        Don't log unnecessarily  [boolean]
  --debug, -s         Log debug messages  [boolean]
  --prompt            Prompt user for missing information  [boolean] [default: "<isTTY>"]
  --confirm           Confirm decisions (only works if prompt=true)  [boolean]

Limitations

Doesn't work on Lerna packages, like babel-register.

Similar projects

gforkforkedgit-forksgit
Forksxxx
Auto-retrieves tokenx
Clonesxxx
Opens a PRxx
Fetches a PRx
Works on GitHub URLsxxxx
Works on NPM package namesx
Works on Bitbucket URLsx
Works on Gitlab URLsx
Https .git url typex
Shallow clonex
rm -rf before cloningx
Execute commands afterwardsx
Use saved configx

-¹: for the time being... GitHub is deprecating the API that makes this possible o²: only https urls

Non-similar but relevant projects:

Not related in any way, but nice little libraries for testing:

1.6.1

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.14.0

8 years ago

0.13.0

8 years ago

0.12.0

8 years ago

0.11.0

8 years ago

0.10.0

9 years ago

0.9.0

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.6.0

9 years ago

0.5.7

9 years ago

0.5.6

9 years ago

0.5.5

10 years ago

0.5.4

10 years ago

0.5.3

10 years ago

0.5.2

10 years ago

0.5.0

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago