Question

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 'git@github.com:<me>/<me>.github.com.git'
Was it helpful?

Solution

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

OTHER TIPS

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.

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"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top