OS: ubuntu 17.10
Node: v6.11.4
npm: 5.6.0
yarn: 1.3.2
(OS, Node, npm, yarn)
error info shows:
$ docusaurus-publish
master
generate.js triggered...
feed.js triggered...
feed.js triggered...
Site built successfully. Generated files in 'build' folder.
Cloning into 'fartpig.github.io-master'...
git clone ok
Note: checking out 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at 254a030... Delete CNAME
fatal: A branch named 'master' already exists.
fatal: could not set upstream of HEAD to origin/master when it does not point to any branch.
Error: Git checkout master failed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
when i git log the branch , they has the same SHA code between the detached commit and master branch.
When I note the code :
if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
} else {
if (
shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
.code !==
0
) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
}
in docusaurus-publish.js , then it works. I thinks this should have a branch check before operation.
+1
Hi @t3573393 @wang701 -- are you trying to publish a user/org site? https://docusaurus.io/docs/en/publishing.html#using-github-pages
@JoelMarcey yes, I am trying to publish a org site.
I have followed the instructions on the page you provided: setting up environment variables (GIT_USER, USE_SSH), setting up a source branch for the web page source, adding a cname in siteConfig.js. When I run the deploy command, it shows the error @t3573393 provided. I have to comment out the same lines of code to deploy.
@wang701 - what version of Docusaurus are you running?
I have a test user site at https://github.com/JoelMarcey/joelmarcey.github.io and I have published it via the publishing steps -- https://joelmarcey.github.io
Do you have your docs and website dir in a different branch other than master? e.g., I have mine in a branch called source
@JoelMarcey from package.json, my docusaurus version is 1.0.5.
I do have my docs and website in a branch other than master (mine is called source as well).
I just upgraded docusaurus to 1.0.7. Problem persists. I should have followed all the instructions correctly on the docusaurus page.
HI @wang701 I just published to my user site. You need to make sure you set the branch to source when you publish:
e.g, my command was:
GIT_USER=JoelMarcey CURRENT_BRANCH=source USE_SSH=true yarn run publish-gh-pages
Also make sure you have the right settings in your siteConfig.js for your project and org. e.g., mine is:
url: 'https://JoelMarcey.github.io' /* your website url */,
baseUrl: '/' /* base url for your project */,
projectName: 'JoelMarcey.github.io',
organizationName: 'JoelMarcey',
Let me know if this helps you.
Here is the output of my publish:
$ GIT_USER=JoelMarcey CURRENT_BRANCH=source USE_SSH=true yarn run publish-gh-pages
Using globally installed version of Yarn
yarn run v1.2.0
warning package.json: No license field
$ docusaurus-publish
source
generate.js triggered...
feed.js triggered...
feed.js triggered...
sitemap.js triggered...
Site built successfully. Generated files in 'build' folder.
Cloning into 'JoelMarcey.github.io-master'...
Note: checking out 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 331b9d2... Deploy website
Switched to a new branch 'master'
Branch master set up to track remote branch master from origin.
rm 'blog/2016/03/11/blog-post.html'
rm 'blog/2017/04/10/blog-post-two.html'
rm 'blog/2017/09/25/testing-rss.html'
rm 'blog/2017/09/26/adding-rss.html'
rm 'blog/2017/10/24/new-version-1.0.0.html'
rm 'blog/atom.xml'
rm 'blog/feed.xml'
rm 'blog/index.html'
rm 'css/main.css'
rm 'docs/doc1.html'
rm 'docs/doc2.html'
rm 'docs/doc3.html'
rm 'docs/doc4.html'
rm 'docs/doc5.html'
rm 'en/help.html'
rm 'en/index.html'
rm 'en/users.html'
rm 'help.html'
rm 'img/docusaurus.svg'
rm 'img/favicon.png'
rm 'img/favicon/favicon.ico'
rm 'img/language.svg'
rm 'img/oss_logo.png'
rm 'index.html'
rm 'sitemap.xml'
rm 'users.html'
331b9d2b43a9c4534846cd5fdd9a63ee055583f1
[master 0b40f35] Deploy website
10 files changed, 52 insertions(+), 40 deletions(-)
create mode 100644 docs/doc6.html
To github.com:JoelMarcey/JoelMarcey.github.io.git
331b9d2..0b40f35 master -> master
Website is live at: https://JoelMarcey.github.io/JoelMarcey.github.io
✨ Done in 14.58s.
@JoelMarcey I looked into publish-gh-pages.js again. For this particular block,
if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
} else {
if (
shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
.code !==
0
) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
}
It means that if the first git checkout origin/${DEPLOYMENT_BRANCH} return code is 0, the script goes to the else block and tries to make a another ${DEPLOYMENT_BRANCH} branch which causes the error @t3573393 and I are experiencing. I am confused by code in the else block.
My rewrite is this:
if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
if (
shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
.code !==
0
) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
}
And it works for me.
@JoelMarcey 's solution work for me, but I need to remove my master branch and set default branch to source.
@st0012 Thanks for the verification. I am surprised you have to remove your master branch though. Setting the proper default branch seems reasonable.
@wang701 Do you want to submit a PR with your suggested fix?
@JoelMarcey I followed what @st0012 said about removing the master branch as well as setting the default branch to source and the original code works. The proposed "fix" is broken...
I still don't fully get why that block was written as it is though (mainly the logic). Can you explain briefly?
@wang701 Hi. Just want to be clear -- when you followed the setting the source as default way and you say the "proposed fix is broken", are you saying your proposed fix to the code is broken?
cc @rickyvetter who updated the publishing script to support user and org pages.
@JoelMarcey yes, my proposed fix, specifically, this rewrite is broken after setting the default branch to source:
if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
if (
shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
.code !==
0
) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
}
I'm running into the same detached HEAD issue. However pages are published but the css is messed up.
@neerajdotname Hi. Do you have your docs in a branch other than master - e.g., source?
I followed what @st0012 said about removing the master branch as well as setting the default branch to source and the original code works. The proposed "fix" is broken...
@wang701 Just curious, now that you got it working after removing the master branch and setting the default branch to source, does it work correctly now on subsequent publishes? In other words, if you publish again does it work without having to remove the master branch again?
@JoelMarcey
does it work correctly now on subsequent publishes?
Yes, it does.
if you publish again does it work without having to remove the
masterbranch again?
Yes. I only removed the master branch once (git branch -D master) and changed the default branch to source on the github website. All subsequent publishes work afterwards.
@wang701 Great. Thanks!
Do you think this is more a documentation issue then? Basically, say more clearly upfront that if you are using an org/user page published on master, that you need to remove your master branch, have your docs on a different branch, publish to master to create it and the publish normally? Something like that?
@JoelMarcey Yeah, I agree.
@JoelMarcey For me it was building and deploying without any problem but it couldn't locate the css and assets directory, on my localhost it was running okay, so I came across this thread and I decided to go with the suggested fix by @wang701, I created the source branch and deleted the master and the build & deployed works properly now.
Thanks @wang701
@wang701 Would you be keen to create a PR to update the documentation?
Hello 👋,
I'm also seeing these errors. I read some of the comments on this thread and not all of them make sense to me.
I have the following setup:
That said, I don't want to write docs anywhere that's not close to the source code, and I also want the simple URL https://express-validator.github.io/.
I don't understand why the source code here...
...would want to _create the branch_ if it finds it in the origin remote. 🤔 🤷♀️
@gustavohenke Hi. I assume you followed the instructions here: https://docusaurus.io/docs/en/publishing.html#using-github-pages, particularly the note deploying to user or organization sites.
Given that #716 gives the correct error message and I see
Docusaurus also supports deploying user or organization sites. These sites will be served from the master branch of the repo. So, you will want to have the Docusaurus infra, your docs, etc. in another branch (e.g., maybe call it source). To do this, just set projectName to "username.github.io" (where username is your username or organization name on GitHub) and organizationName to "username". The publish script will automatically deploy your site to the root of the master branch to be served.
At https://docusaurus.io/docs/en/publishing.html#using-github-pages
I think less user will find this error. Should we close this @joelmarcey @yangshun?
Closed by #716 & #764