DEV Community

Discussion on: How to deploy React App to GitHub Pages

Collapse
 
trishabernice profile image
trishabernice

Hi! Thanks for the tutorial!

I accidentally copy pasted this on my terminal : git remote add origin git@github.com:Yuribenjamin/my-app.git

and now i keep getting this:
Cloning into 'node_modules/gh-pages/.cache/git@github.com!Yuribenjamin!my-app.git'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 deploy: gh-pages -d build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@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! /Users/TrishaBernice/.npm/_logs/2020-06-15T16_41_28_880Z-debug.log

I tried git remote rm origin and it still won't work. can you please advice me on what i should do here? I will really appreciate it!

Collapse
 
averyfreeman profile image
Avery Freeman

If you don't have any commits you're worried about losing, you can just delete the .git folder.

Collapse
 
chuchhin profile image
Jesús Sánchez • Edited

I'd the same problem and then read a lot of blogs/articles I find the solution. I'd changed the git in my PATH in this question you can find the solution then open the a new terminal and run the command npm run deploy I hope this help you.

Regards.

Collapse
 
yuribenjamin profile image
Ibrahim Ragab

No problem
git remote - v
Will display origin and the wrong remote url
To delete it
git remote rm origin
Then check again
git remote - v
Will display nothing time to add the right one
Happy Hacking

Collapse
 
trishabernice profile image
trishabernice

Hi Ibrahim, Thanks for the fast reply!

I did this:
Trishas-MBP-2:src TrishaBernice$ git remote rm origin
Trishas-MBP-2:src TrishaBernice$ git remote -v
Trishas-MBP-2:src TrishaBernice$ git remote add origin git@github.com:trishabernice/portfolio.git
Trishas-MBP-2:src TrishaBernice$ npm run deploy

and I still got this...
Cloning into 'node_modules/gh-pages/.cache/git@github.com!Yuribenjamin!my-app.git'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 deploy: gh-pages -d build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@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! /Users/TrishaBernice/.npm/_logs/2020-06-15T17_01_16_913Z-debug.log

Is there anything else I can try to fix the issue?

Thread Thread
 
yuribenjamin profile image
Ibrahim Ragab

Use http or ssh

Thread Thread
 
trishabernice profile image
trishabernice

Earlier I did this:
Trishas-MBP-2:src TrishaBernice$ git remote add origin github.com/trishabernice/portfolio...
and i did git remote rm origin and then added the one for ssh and I still got the same error.

Thread Thread
 
trishabernice profile image
trishabernice

Do you have any suggestions for what I can do? I'll really appreciate it!

Thread Thread
 
mejimaru profile image
mejimaru • Edited
  1. go to github.com and create Repositories => your-app
  2. create your personal access token github.com/settings/tokens
  3. git remote set-url origin username:yourtoken@github.com/user...
  4. npm run deploy

or

  1. yarn add gh-pages
  2. yarn deploy
Thread Thread
 
sherazzie profile image
Sherazzie

mejimaru's solution worked if anyone ran into the error that @trishabernicer faced.

Thanks @mejimaru

Collapse
 
lathryx profile image
Lathryx

In response to @trishabernice 's problem with node_modules/.cache/gh-pages, a fix with this for me was to simply remove/delete node_modules/.cache/gh-pages, then execute npm run deploy once more.

This issue I'm referring to (and its answer) can be found on StackOverflow here: stackoverflow.com/questions/639645...