Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: A branch named 'gh-pages' already exists

Tags:

git

github

gatsby

I made a template sale website (gatsby / react). I cloned my template GitHub repo and changed the remote origin to a new private repo, pushing to which works fine.

I deploy to gh-pages with npm srcipt "deploy": "gatsby build --prefix-paths && gh-pages -d public" The first time I ran this command it seemed to stall so I control c'd out of it. Now, when I try to deploy I get the error "fatal: A branch named 'gh-pages' already exists."

git branch -a shows: remotes/origin/HEAD -> origin/master remotes/origin/gh-pages remotes/origin/master

But there is not a gh-pages branch on gitHub.

I tried rm -rf node_modules/gh-pages/.cache didn't work. Also, git push origin --delete gh-pages which gave "error: unable to delete 'gh-pages': remote ref does not exist".

I uninstalled and reinstalled gh-pages.

like image 603
eoja Avatar asked Sep 19 '20 01:09

eoja


People also ask

Is there a branch named 'GH-pages' on GitHub?

fatal: A branch named 'gh-pages' already exists. · Issue #44 · gitname/react-gh-pages · GitHub Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Is there a branch named'GH-pages'available?

fatal: A branch named 'gh-pages' already exists. · Issue #15 · transitive-bullshit/react-modern-library-boilerplate · GitHub Have a question about this project?

What does “fatal” mean in shell script?

“fatal: A branch named 'gh-pages' already exists.” Code Answer fatal: A branch named 'gh-pages' already exists. Shell/Bash answers related to “fatal: A branch named 'gh-pages' already exists.” fatal: remote origin already exists.

How to fix Git checkout--orphan GH-pages fails?

Delete the local branch gh-pages if exists and run the command again. If already exists a gh-pages in your local, git checkout --orphan gh-pages will fail.


2 Answers

I had to manually remove the folder node_modules/.cache/gh-pages to get the deployment to work.

Prior to this I had tried git fetch --prune, which removed remotes/origin/gh-page. I don't know if pruning the branches was a necessary step or not.

like image 71
eoja Avatar answered Oct 12 '22 02:10

eoja


Just manually deleting the folder node_modules/.cache/gh-pages worked.

like image 19
KushalSeth Avatar answered Oct 12 '22 00:10

KushalSeth