DEV Community

Cover image for Fixed 'fatal: Couldn't find remote ref refs/heads/gh-pages' after running:git push origin :gh-pages'
yuvaraj
yuvaraj

Posted on

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.

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

Top comments (0)