fatal: A branch named 'gh-pages' already exists.
okezieokpara opened this issue ยท 42 comments
When, I run the npm run deploy
command, I get this error: fatal: A branch named 'gh-pages' already exists.
I can't say what the issue is. The homepage
property in my package.json file is: "https://okezieokpara.github.io/custom-react-app-example"
Closing as resolved; please feel free to reopen if you're still having an issue.
Hi @transitive-bullshit : A branch named 'gh-pages' already exists
I tried using command rm -rf node_modules/gh-pages/.cache but for this -rf is not recognised..
Thanks in advance.
@ergauravgoyal what OS are you using?
rm -rf node_modules/gh-pages/.cache worked for me
Hello @ergauravgoyal the rm -rf node_modules/gh-pages/.cache
command doesn't work on windows. You can delete the file manually
hey what are the files which we have to delete manually ?
Go to your project's node_modules/gh-pages and delete '.cache' folder. (Manually deleting works).
Given the number of people running into this, I think it may make sense to add this to a predeploy step to ensure that nobody gets tripped by this in the future.
For me, manually deleting node_modules/gh-pages/.cache
brought up another issue- tschaub/gh-pages#230
I followed the post to run git config --global credential.helper wincred
and it worked finally.
I was running on Win 10.
parmeet9891 thanks man. its working fine..
Hello @ergauravgoyal the
rm -rf node_modules/gh-pages/.cache
command doesn't work on windows. You can delete the file manually
hello,it worked on windows7 os.
i had
"deploy": "gh-pages -d build",
when I should of had
"deploy": "gh-pages -b master -d build",
hey what are the files which we have to delete manually ?
on windows, you should install rimraf
npm install -g rimraf
then rimraf node_modules/gh-pages/.cache
On Windows you can also run
rmdir /S /Q node_modules\gh-pages\.cache
This won't require you to install anything.
In Powershell can be done using:
Remove-Item -Force -Recurse -Path ./node_modules\gh-pages\.cache
I was running git version 2.14 and updated to the last version in this moment, 2.26.2 and worked for me
We're using gh-pages under the hood. A quick search for that error gives the issue along with advice on fixing it.
Try:
rm -rf node_modules/gh-pages/.cache
What is an equivalent script I should run on a windows 10 machine? I'm encountering this problem but rm "is not recognized as an internal or external command, operable program or batch file."
i had
"deploy": "gh-pages -d build",
when I should of had
"deploy": "gh-pages -b master -d build",
This worked for me but what does -b master
it do?
change the repository name same as app name. worked fine for me
Update and possible solution:
I was able to get gh-pages
to work correctly:
- Traverse the file structure of the project to
node_modules/gh-pages/bin/gh-pages-clean.js
- Run
gh-pages-clean.js
- Create a new build of the project via
npm run build
- Lastly, deploy again to GitHub pages via
npm run deploy
Sorry for deleting my earlier comment. I didn't know if this was the correct location to talk about the issue that I was encountering. I have now re-added it for the sake of the discussion.
gh-pages-clean
worked for me.
Adding to the steps @adamalston mentioned, you can add a script in package.json
like this.
'clean' : 'gh-pages-clean'
So you'll just need to do npm run clean
next time the cleaning is required.
Go to your project's node_modules/gh-pages and delete '.cache' folder. (Manually deleting works).
I can't find such folder while trying to do it manually.
gh-pages-clean
worked for me.
Adding to the steps @adamalston mentioned, you can add a script inpackage.json
like this.'clean' : 'gh-pages-clean'
So you'll just need to do
npm run clean
next time the cleaning is required.
It worked for me. Thanks everyone.
Go to your project's node_modules/gh-pages and delete '.cache' folder. (Manually deleting works).
Thanks, now works
fatal: A branch named 'gh-pages' already exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! news-app@0.1.0 deploy: gh-pages -d build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the news-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!
gh-pages-clean
worked for me.
Adding to the steps @adamalston mentioned, you can add a script inpackage.json
like this.'clean' : 'gh-pages-clean'
So you'll just need to do
npm run clean
next time the cleaning is required.
This solved my issue. this should work regardless of the OS you are running.
The solution has stopped working.
What worked for me was:
rm -rf node_modules/.cache/gh-pages/
gh-pages-clean
worked for me.
Adding to the steps @adamalston mentioned, you can add a script inpackage.json
like this.'clean' : 'gh-pages-clean'
So you'll just need to do
npm run clean
next time the cleaning is required.
it works for me thanks so much
the path above didnt work for me, but removing this worked rm -rf node_modules/.cache/gh-pages
I'm using windows 10 2004. This code works rm -rf node_modules/gh-pages/.cache
Thanks.
designdust.me
gh-pages-clean
worked for me.
Adding to the steps @adamalston mentioned, you can add a script inpackage.json
like this.'clean' : 'gh-pages-clean'
So you'll just need to do
npm run clean
next time the cleaning is required.This solved my issue. this should work regardless of the OS you are running.
after running this also I found the same error
fatal: unable to access 'https://github.com/rustwasm/create-wasm-app.git/': The requested URL returned error: 403
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-wasm-app@0.1.0 deploy: `gh-pages -d dist`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the create-wasm-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:
this error
fatal: A branch named 'gh-pages' already exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-wasm-app@0.1.0 deploy: `gh-pages -d dist`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the create-wasm-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:
replace "deploy": "gh-pages -d build" code to "deploy": "gh-pages -b master -d build" in scripts section the package.json. This was worked for me and after publishing successfully, goes to the github-pages in the repository setting and set source to the master.
this will work!!!
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.
Just manually go to node_modules/.cache/gh-pages and delete gh-pages it works guys.
This happens when npm run deploy
fails for any reason. it generates a copy of the file in your project =>
project/node_modules/.cache/gh-pages
Just delete the culprit manually or the command rm -rf node_modules/.cache/gh-pages/
Noted for myself in case i get the same error :)
gh-pages-clean
worked for me. Adding to the steps @adamalston mentioned, you can add a script inpackage.json
like this.'clean' : 'gh-pages-clean'
So you'll just need to do
npm run clean
next time the cleaning is required.
โคโคโคโคโคโค๐๐๐๐๐โคโคโคโคโค๐ค
Thanks Brother its working
I got the same error - fatal: A branch named 'gh-pages' already exists.
when i run npm run deploy
to deploy my react app to github pages
I am not sure about the reason why its saying branch already exists but what i have done is
- manually deleted
build
folder that was created as part of above failed command, otherwise next time we run deploy command it is complaining that build folder already exists - manually created a new branch
gh-pages
from mymain
branch in my remote git repository - updated deploy command to
"deploy": "gh-pages -b gh-pages -d build"
After doing the above three steps, once again I have executed npm run deploy
and my react app code got published successfully!!
Now I have dev code in main
branch and prod build static code in gh-pages
branch
gh-pages -b master -d build
This worked for me. Thank you