Reputation: 3039
Here is my git repo for time tracking: Click here!!
I wanted to host that project in git pages. So I followed these steps:
- Create a repo with the name, username.github.io. I created a new repo akulkarni9.github.com.
- Open the repository's page on GitHub.
- In your repository's right sidebar, click settings.
- Click the Automatic Page Generator button and author my content in markup editor.
- Click the Continue To Layouts button
- Preview your content in our themes.
- When you find a theme that you like, click Publish page.
I did exact things as mentioned in those steps. When I opened akulkarni.github.io
in a browser, that project wasn't hosted.
Then I executed the following commands:
cd to repository in local system
git fetch origin
Output was:
remote: Counting objects: 56, done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 56 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (56/56), done.
From https://github.com/akulkarni9/akulkarni9.github.io
7ac8179..651c795 master -> origin/master
Then I executed this command:
git checkout gh-pages
And I got an error:
error: pathspec 'gh-pages' did not match any file(s) known to git.
Where did I go wrong?
Upvotes: 0
Views: 570
Reputation: 1223
Your repository only has a master
branch, it doesn't have a gh-pages
branch. That's what the error says.
If you want to create that branch locally, you should do the following:
git checkout -b gh-pages
Instead of this:
git checkout gh-pages
Or, as the documentation suggests:
git checkout --orphan gh-pages
Which will create the branch without any parents.
Update
Now that you've set up the gh-pages
branch locally, you'll need to add content to it and push the branch to your remote repository. You can do that as follows (taken from the documentation):
echo "My Page" > index.html
git add index.html
git commit -a -m "First pages commit"
git push origin gh-pages
If you've done the above. You will have an index.html
file with My Page
as its content. Just edit that file (to what ever you want it to be) and push your changes:
git add index.html
git commit -a -m "Updated the index.html file."
git push origin gh-pages
That should do it. Also, take note of one of the last lines of the documentation:
After your push to the
gh-pages
branch, your Project Pages site will be available athttp(s)://<username>.github.io/<projectname>
Update, Part II
If you're still having problems after all of this, there is an option to create Project Pages with the automatic generator.
Update, Part III
Ok, so instead of creating gh-pages
branch in your Github site, create that branch in the repository you want to show as a Project Page.
So, let's say you want your Time Tracker project as a Project Page:
gh-pages
branch in your TimeTracker project (as you've previously done in your *.github.io
repository). Upvotes: 2
Reputation: 10984
Are you sure you completed the final step & hit the "Publish page" button?
When you hit this button, GitHub will create a new branch into which it commits the settings & code behind your project page. Once your page is created, you'll be able to see it listed in the branch selector on your main project page.
For example, if you look at my Magic8Ball project, you'll be able to find the gh-pages branch for the project's GitHub page.
Once you have the branch configured in GitHub, pull the project you cloned previously and you'll be able to see the new gh-pages branch arrive:
> git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 11 (delta 0), reused 0 (delta 0), pack-reused 7
Unpacking objects: 100% (11/11), done.
From github.com:bitcrazed/Magic8Ball
* [new branch] gh-pages -> origin/gh-pages
Already up-to-date.
You'll now be able to checkout the new gh-pages
branch:
> git checkout -t origin/gh-pages
Branch gh-pages set up to track remote branch gh-pages from origin.
Switched to a new branch 'gh-pages'
HTH.
Upvotes: 0
Reputation: 38
A few things you can do when you get the message
error: pathspec 'gh-pages' did not match any file(s) known to git.
From Git Bash:
git branch -a (show all branches, local and remote).
If your branch branch-name does not appear on the list under local or remote it means branch-name does not exist locally or on your remote repository.
Create it locally w/ git checkout -b branch-name
If the desired branch is found remote, you can check it out w/
git checkout -b branch-name origin/branch-name
Good source for Git documentation.
Git cheat sheet for quick reference.
Also, you created the repo akulkarni9.github.com when the .com subdomain is deprecated by GitHub Pages. You should try recreating the repo as akulkarni9.github.io instead.
Upvotes: 0