gh-pages icon indicating copy to clipboard operation
gh-pages copied to clipboard

branch: "master" option appears to fail

Open bebraw opened this issue 9 years ago • 13 comments

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.

bebraw avatar Mar 07 '15 19:03 bebraw

Honest question: why are you trying to replace master?

markdalgleish avatar Mar 07 '15 20:03 markdalgleish

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.

bebraw avatar Mar 07 '15 20:03 bebraw

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?

markdalgleish avatar Mar 07 '15 20:03 markdalgleish

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.

bebraw avatar Mar 07 '15 20:03 bebraw

So, in your current setup, can you deploy to master while in the gh-pages branch?

markdalgleish avatar Mar 07 '15 21:03 markdalgleish

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.

bebraw avatar Mar 07 '15 21:03 bebraw

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.

markdalgleish avatar Mar 07 '15 21:03 markdalgleish

Can you have a look at my proposed fix at some point?

bebraw avatar May 31 '15 07:05 bebraw

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.

stewartduffy avatar Oct 24 '17 19:10 stewartduffy

Getting the same error

hyperh avatar Oct 26 '17 01:10 hyperh

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?

zhnoah avatar Dec 20 '17 04:12 zhnoah

I am also missing the feature as GitHub personal pages require to use the master branch.

stefan-wegener avatar Dec 25 '17 20:12 stefan-wegener

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

tom-con avatar May 22 '18 18:05 tom-con