gh-pages
gh-pages copied to clipboard
branch: "master" option appears to fail
I have set up a little cli wrapper for gh-pages
. While testing it I noticed it doesn't allow master branch to be replaced. It emits
{ [ProcessError: fatal: A branch named 'master' already exists.
]
code: 128,
message: 'fatal: A branch named \'master\' already exists.\n',
name: 'ProcessError' }
I managed to write a little script like this to work around the issue:
# go to the out directory and create a *new* Git repo
cd build
# Remove possible existing git repo. We'll replace entire gh-pages.
rm -rf .git
# Init new repo
git init
# The first and only commit to this new Git repo contains all the
# files present with the commit message "Deploy to GitHub Pages".
git add .
git commit -m "Deploy to GitHub Pages"
# Add origin
git remote add origin <my repo>
# Force push from the current repo's master branch to the remote
# repo's master branch. (All previous history on the master branch
# will be lost, since we are overwriting it.)
git push --force origin master:master
Maybe this could give you some idea on how to fix the issue.
Honest question: why are you trying to replace master?
Honest question: why are you trying to replace master?
I am deploying an org site to GitHub Pages. Ironically it looks for the content at master
, not gh-pages
.
If that's the case, wouldn't it be better to have a src
branch so that it doesn't get overridden when you deploy?
If that's the case, wouldn't it be better to have a src branch so that it doesn't get overridden when you deploy?
Yeah, we actually treat gh-pages
as our source branch at the moment (probably should rename to src
, yup). Then we deploy HTML at master
. Only master
gets overridden as we are limited by GitHub org conventions here.
So, in your current setup, can you deploy to master
while in the gh-pages
branch?
So, in your current setup, can you deploy to master while in the gh-pages branch?
Yeah, the custom script works while the library version doesn't. As you can see the script just sets up a repo, makes it point to GH and force pushes stuff. Maybe there's some subtle difference.
By the way deployment to some other branch seemed to work so it's likely something special with master.
Would you be able to try fixing the library for your use case and let me know how you go? If not, I'll have a look as soon as I can.
Can you have a look at my proposed fix at some point?
Any updates on this? I am using this to publish to my user site on GitHub pages. Current workflow is I work on a src branch, and would like to deploy built files straight to master. But when I try to specify the following "deploy": "gh-pages -b master -d build"
I get the same error as above. fatal: A branch named 'master' already exists.
Getting the same error
When I use "deploy": "gh-pages -b master -d build"
in src
branch,
get the same error fatal: A branch named 'master' already exists.
,
but I confirm that the master
branch has been deleted,
has anyone solved it?
I am also missing the feature as GitHub personal pages require to use the master branch.
I solved this issue for myself by following the highly upvoted answer here.
Basically by deleting the cache by:
rm -rf node_modules/gh-pages/.cache