Failed to get remote.origin.url

Viewed 892

When trying to use gh-pages to deploy a react app I get the following error

...
$ gh-pages -d build
Failed to get remote.origin.url (task must either be run in a git repository with a configured origin remote or must be configured with the "repo" option).
...

The remote is set as origin

$ git remote -v
origin  https://github.com/{user_name}/{repo_name} (fetch)
origin  https://github.com/{user_name}/{repo_name} (push)
2 Answers

I was searching for an answer too and found that I could work this around with docker.

  1. Install and setup docker in your machine - https://docs.docker.com/get-docker/

  2. Install node:12-alpine image - docker run node:12-alpine

  3. start a container

  4. Install github-cli and git in the container - apk update; apk add git; apk add github-cli;

  5. Authenticate github-cli with PAT from Github - https://github.com/settings/tokens

  6. install gh-pages - npm i -D gh-pages

  7. Run ./node_modules/.bin/gh-pages -d build

  8. check whether the source of the project is set to the root of the gh-pages branch - https://github.com/user/repo/settings/pages

The solution for me was that I had a remote origin set, however it would throw me this error when my project folder was located on an external hard drive. Made a new react project on my local hard drive and now it works despite everything else being the same.

Related