Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MarkChenYutian opened this issue Aug 28, 2022 · 2 comments

Comments

@MarkChenYutian
Copy link

MarkChenYutian commented Aug 28, 2022

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   

> c0vm-ts@0.1.0 predeploy
> npm run build


> c0vm-ts@0.1.0 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


> c0vm-ts@0.1.0 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).
@nyraa
Copy link

nyraa commented Oct 23, 2022

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

@sreenathkumar
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants