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

4 1

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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs