gh-pages icon indicating copy to clipboard operation
gh-pages copied to clipboard

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

Open wzup opened this issue 6 years ago • 7 comments
trafficstars

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

$ git remote -v
origin  [email protected]:wzup/wzup.github.repo.git (fetch)
origin  [email protected]:wzup/wzup.github.repo.git (push)
prod    [email protected]:wzup/wzup.github.io.git (fetch)
prod    [email protected]: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! [email protected] deploy: `gh-pages -b master -d build --remote prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

wzup avatar Apr 09 '19 14:04 wzup

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

kalvinpearce avatar Jul 24 '19 07:07 kalvinpearce

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.

benpryke avatar Jul 27 '19 17:07 benpryke

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.

joan38 avatar Feb 09 '20 21:02 joan38

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

Victoire44 avatar Feb 09 '20 22:02 Victoire44

Seems to be fixed, following works for me now:

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

TheTimeBandit avatar Jul 30 '20 20:07 TheTimeBandit

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

milesfrain avatar Aug 02 '20 01:08 milesfrain

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

Where to put this and when

Manishashaw avatar Feb 24 '21 19:02 Manishashaw