Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’

Oh, this is weird 🙁

After a long time, I planned to deploy my react app to github in a different path, so I removed the gh-pages branch from my previously deployed path.
Then, I tried to my deploy app.
Oh, I didn’t expect this error should come up…


This content originally appeared on DEV Community and was authored by yuvaraj_11

Oh, this is weird :(

  • After a long time, I planned to deploy my react app to github in a different path, so I removed the gh-pages branch from my previously deployed path.
  • Then, I tried to my deploy app.

  • Oh, I didn't expect this error should come up.

Error-

  • I had been trying to fix the issue for a while , but finally a simple trick did work well.

  • This is my script which I had it before the error was occurred.

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},

  • I changed only the deploy script from "deploy": "gh-pages -d build" to "deploy": "gh-pages-clean gh-pages -d build".

  • Then, I tried npm run deploy, now the gh-pages cache got removed and ready to capture new changes.

  • After that, I changed the deploy script back to normal "deploy": "gh-pages -d build".

  • Now, I ran npm run deploy, now it worked like a charm :)

Fixed


This content originally appeared on DEV Community and was authored by yuvaraj_11


Print Share Comment Cite Upload Translate Updates
APA

yuvaraj_11 | Sciencx (2022-04-14T12:38:45+00:00) Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’. Retrieved from https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/

MLA
" » Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’." yuvaraj_11 | Sciencx - Thursday April 14, 2022, https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/
HARVARD
yuvaraj_11 | Sciencx Thursday April 14, 2022 » Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’., viewed ,<https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/>
VANCOUVER
yuvaraj_11 | Sciencx - » Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/
CHICAGO
" » Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’." yuvaraj_11 | Sciencx - Accessed . https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/
IEEE
" » Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’." yuvaraj_11 | Sciencx [Online]. Available: https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/. [Accessed: ]
rf:citation
» Fixed ‘fatal: Couldn’t find remote ref refs/heads/gh-pages’ after running:git push origin :gh-pages’ | yuvaraj_11 | Sciencx | https://www.scien.cx/2022/04/14/fixed-fatal-couldnt-find-remote-ref-refs-heads-gh-pages-after-runninggit-push-origin-gh-pages/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.