Skip to content

Instantly share code, notes, and snippets.

@jeremyben
Last active August 9, 2023 02:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyben/038ed0ec60620b5d4785f998ce88678a to your computer and use it in GitHub Desktop.
Save jeremyben/038ed0ec60620b5d4785f998ce88678a to your computer and use it in GitHub Desktop.
Proper fork workflow for a node module repo that does'nt want to merge your perfectly fine pull request.

Fork it

Clone your fork :

git clone git@github.com:YOU/FORK

Add the original repo as an remote :

git remote add upstream git@github.com:HIM/BASE

Change it

Hack away.

You can also merge other pull requests. First get the pull request ID from the original repo and then pull :

git pull git@github.com:HIM/BASE/refs/pull/153/head

Branch it

To avoid publishing on npm, branch with a name referencing the original module version :

git checkout -b 1.1.0-a

Build it

  • In .gitignore, remove lines referring to the build folder (e.g. dist or build).
  • Build the project (e.g. npm run build).
  • Check that package.json has a main property linking to the build entry point (e.g. dist/index.js).

Use it

In your app's package.json, assign the branch of your fork instead of the usual npm version :

{
  "dependencies": {
    "module": "YOU/FORK#1.1.0-a"
  }
}

Sync it

git fetch upstream
git checkout master
git merge upstream/master

Then branch it, build it, use it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment