tschaub / gh-pages

General purpose task for publishing files to a gh-pages branch on GitHub
https://www.npmjs.com/package/gh-pages
MIT License
3.25k stars 191 forks source link

gh-pages does not recognize configured remote repo ( -o, --remote <name>) #290

Open wzup opened 5 years ago

wzup commented 5 years ago

I have two remote repositories in my git, origin and prod. Both exist on GitHub too:

$ git remote -v
origin  git@github.com:wzup/wzup.github.repo.git (fetch)
origin  git@github.com:wzup/wzup.github.repo.git (push)
prod    git@github.com:wzup/wzup.github.io.git (fetch)
prod    git@github.com:wzup/wzup.github.io.git (push)

I have configured gh-pages to deploy to prod repo (not to origin) as written here:

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -b master -d build --remote prod" // <== Here '--remote prod'
  },

Why do I get error? How to fix? This is really a bug according to documents

The default is your 'origin' remote, but this can be configured to push to any remote.

$ npm run deploy

Failed to get remote.prod.url (task must either be run in a git repository with a configured prod remote or must be configured with the "repo" option).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! muses@0.1.0 deploy: `gh-pages -b master -d build --remote prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the muses@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-04-debug.log
kalvinpearce commented 5 years ago

Having same issue. Quick workaround is use --repo <url> or -r <url>

benpryke commented 5 years ago

I have the same issue. It's strange, because the command that gh-pages is running is simply git config --get remote.<remote name>.url, and I can execute that in the shell without issue. Perhaps the call is failing within child_process for an unexpected reason.

joan38 commented 4 years ago

Hey, I came across this issue via this StackOverflow. The solution worked thanks to @kalvinpearce's super useful comment.

How are we supposed to know that those options (--repo, -b...) exists? The documentation (README.md) doesn't even mention anything. There is only snippets of code we have no idea where to stick them in.

Victoire44 commented 4 years ago

I added them to the readme here: https://github.com/tschaub/gh-pages/pull/333

TheTimeBandit commented 4 years ago

Seems to be fixed, following works for me now:

gh-pages -d build -b master --remote gh-pages

milesfrain commented 4 years ago

Was having issues with this command in version 2.2.0, but can confirm this is now fixed in version 3.1.0.

gh-pages --remote tps -d dist
Manishashaw commented 3 years ago

Having same issue. Quick workaround is use --repo <url> or -r <url>

Where to put this and when