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

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).

Open MarkChenYutian opened this issue 3 years ago • 5 comments

Description

When I'm trying to deploy my react app created using create-react-app on GitHub pages, I received this error message when executing gh-pages -d build.

Attempts

I've followed the instructions in issue #192 as an attempt to fix the problem. However, non of them works (git remote add origin, changing gh-pages CLI argument, bumping gh-pages version, ...etc.)

  1. I've checked the git remote and the remote origin exists.
    (base) PS E:\c0vm-ts> git remote -v
    origin  https://github.com/MarkChenYutian/C0VM-ts.git (fetch)
    origin  https://github.com/MarkChenYutian/C0VM-ts.git (push)
    
  2. I've also tried to change gh-pages's CLI arguments as mentioned in #192 to set repo URL with -r option
    // package.json
    {
    "name": "c0vm-ts",
    "version": "0.1.0",
    "homepage": "https://markchenyutian.github.io/C0VM-ts/build/",
    "private": true,
    "dependencies": {
     "@babel/core": "^7.16.0",
     // omit some irrelevant dependencies ...
     "gh-pages": "^4.0.0",
     // omit some irrelevant dependencies ...
    },
    "scripts": {
      "start": "craco start",
      "build": "craco build",
      "test": "react-scripts test",
      "predeploy": "npm run build",
      "deploy": "gh-pages -d build -r https://github.com/MarkChenYutian/C0VM-ts.git"
    },
    }
    
  3. I've also tried to remove remote origin and then add it again with
    (base) PS E:\c0vm-ts> git remote add origin https://github.com/MarkChenYutian/C0VM-ts.git
    

But none of these work...

Error Message

(base) PS E:\c0vm-ts> npm run deploy   

> [email protected] predeploy
> npm run build


> [email protected] build
> craco build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  388.81 kB  build\static\js\main.118b6891.js
  69.9 kB    build\static\css\main.9f7e2885.css

The project was built assuming it is hosted at /C0VM-ts/build/.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.

Find out more about deployment here:

  https://cra.link/deployment


> [email protected] deploy
> gh-pages -d build -r https://github.com/MarkChenYutian/C0VM-ts.git

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).

MarkChenYutian avatar Aug 28 '22 15:08 MarkChenYutian

This issue also happens to me.

What I found

In my case, my repo is in the external drive. And git adds new policy after version 2.35.2 that will prevent git command executes in repo on external drive until add a exception for that directory in git config. When deploying, gh-pages will clone a repo to node_modules/.cache/gh-pages , but running git command in that repo are blocked by the policy. So when gh-pages try to run git config --get remote.$REMOTE.url in that cloned repo to get the remote setting will get exit code 1 from git command. By default, gh-pages consider that remote dosen't exists and throw error

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).

Workaround

add that cache repo path or * to git global config safe.directory

nyraa avatar Oct 23 '22 06:10 nyraa

I was also facing the same problem. So i deleted the node_modules folder and then reinstalled all the packages by putting yarn command. If you use npm then you can use npm i to reinstall the packages.

sreenathkumar avatar Sep 25 '23 10:09 sreenathkumar

Description

When I'm trying to deploy my react app created using create-react-app on GitHub pages, I received this error message when executing gh-pages -d build.

Attempts

I've followed the instructions in issue #192 as an attempt to fix the problem. However, non of them works (git remote add origin, changing gh-pages CLI argument, bumping gh-pages version, ...etc.)

  1. I've checked the git remote and the remote origin exists.
    (base) PS E:\c0vm-ts> git remote -v
    origin  https://github.com/MarkChenYutian/C0VM-ts.git (fetch)
    origin  https://github.com/MarkChenYutian/C0VM-ts.git (push)
    
  2. I've also tried to change gh-pages's CLI arguments as mentioned in 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) #192 to set repo URL with -r option
    // package.json
    {
    "name": "c0vm-ts",
    "version": "0.1.0",
    "homepage": "https://markchenyutian.github.io/C0VM-ts/build/",
    "private": true,
    "dependencies": {
     "@babel/core": "^7.16.0",
     // omit some irrelevant dependencies ...
     "gh-pages": "^4.0.0",
     // omit some irrelevant dependencies ...
    },
    "scripts": {
      "start": "craco start",
      "build": "craco build",
      "test": "react-scripts test",
      "predeploy": "npm run build",
      "deploy": "gh-pages -d build -r https://github.com/MarkChenYutian/C0VM-ts.git"
    },
    }
    
  3. I've also tried to remove remote origin and then add it again with
    (base) PS E:\c0vm-ts> git remote add origin https://github.com/MarkChenYutian/C0VM-ts.git
    

But none of these work...

Error Message

(base) PS E:\c0vm-ts> npm run deploy   

> [email protected] predeploy
> npm run build


> [email protected] build
> craco build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  388.81 kB  build\static\js\main.118b6891.js
  69.9 kB    build\static\css\main.9f7e2885.css

The project was built assuming it is hosted at /C0VM-ts/build/.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.

Find out more about deployment here:

  https://cra.link/deployment


> [email protected] deploy
> gh-pages -d build -r https://github.com/MarkChenYutian/C0VM-ts.git

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).

That Work For Me

aaravaggarwal3535 avatar May 15 '24 13:05 aaravaggarwal3535