Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I publish to <me>.github.com?

Tags:

git

branch

github

I've read the guide, which tells you to do the following:

  1. create a .github.com repository
  2. check it out to path/to/repo
  3. cd /path/to/repo
  4. git symbolic-ref HEAD refs/heads/gh-pages
  5. rm .git/index
  6. git clean -fdx
  7. echo "My GitHub Page" > index.html
  8. git add .
  9. git commit -a -m "First pages commit"
  10. git push origin gh-pages

I've done that. And the page shows up. Then I moved to a different computer and checked out the repository again. Now I have a "master" branch in my local, but no "gh-pages." And following steps 3-6 above leaves me with no files in that branch. How do I get the files from "master" into the branch that will publish to GitHub?

I tried git checkout master && git push origin gh-pages but that yields

error: src refspec gh-pages does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push to '[email protected]:<me>/<me>.github.com.git'
like image 844
James A. Rosen Avatar asked May 22 '09 00:05

James A. Rosen


People also ask

How do I publish my GitHub site?

Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Pages. To see your published site, under "GitHub Pages", click your site's URL. Note: It can take up to 10 minutes for changes to your site to publish after you push the changes to GitHub.

What does it mean to publish to GitHub?

You can publish a package to GitHub Packages to make the package available for others to download and re-use.

Can you publish from GitHub?

You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site. People with admin or maintainer permissions for a repository can configure a publishing source for a GitHub Pages site.


3 Answers

Apparently subsequent pushes to "origin master" actually do the trick! It's not documented in the guide, though.

like image 101
James A. Rosen Avatar answered Sep 22 '22 05:09

James A. Rosen


As Gaius says, you are following the directions for 'Project Pages', but you are not trying to create a project page, you are trying to create a user page. Creating a user page is much easier - you just create a '.github.com' repository then push your website files to it's master branch, like you would any other normal project.

The instructions you are trying to follow are for adding a parallel branch containing website files to an already existing project. We don't want to make you add a 'website' subdirectory or something to your project, so instead we have you create a completely new branch and push your website to that unrelated branch - thus the Git trickery there.

like image 41
Scott Chacon Avatar answered Sep 21 '22 05:09

Scott Chacon


To work on a branch of a fresh remote repository checkout you will first need to create the branch locally. Here is an example for a “gh-pages” branch:

git checkout --track -b gh-pages origin/gh-pages

More details in this article "Migrating project websites to github pages"

like image 32
VonC Avatar answered Sep 20 '22 05:09

VonC