Reputation: 4653
I have the following setup of an app I am working on, and I would like to host the app on github using gh-pages. here I hope to achieve this.
UserName@PC1 ~/GitHub/ud989-retain
$ ls
css index.html js
UserName@PC1 ~/GitHub/ud989-retain
$ git status
# On branch master
nothing to commit (working directory clean)
UserName@PC1 ~/GitHub/ud989-retain
$ git branch
* master
below is what I do to get my page hosted on gihub gh-pages
# create the gh-pages branch
git branch gh-pages
# think this copies all files from master/origin to gh-pates(remotely and locally I think?)
git push origin gh-pages
# this shows the branches available(master and gh-pages and you should be on master)
git branch
# change to the gh-pages branch
git checkout gh-pages
#get the status of your repo, it should be upto date
git status
# this shows the branches available(master and gh-pages and you should be on gh-pages)
git branch
# create a .nojekyll, not sure what this does exactly but it is required
touch .nojekyll
# you should be able to see your .nojekyll
ls -a
# now add your .nojekyll for committing, not sure why i don't have to commit the others but maybe they are done with the git push origin gh-pages
git add .nojekyll
# commit the file with a comment
git commit -a -m "adding .nojekyll file"
# this gives the remote URLs, not required but just checking they are there
git remote -v
# push to your remote repo, and I should be able to view my page online
git push origin gh-pages
So the end result will be 2 branches in your github account, master and gh-pages and they should have the same files. Then you should get a link to where your page is hosted.This can be found in the settings of your git hub account.
EDIT1 Once the above is done if you go yo your github page with your repo and select settings, under Gihub pages you should have for example: GitHub Pages Your site is published at http://hattricknz.github.io/ud989-retain.
NOTE I have searched various places for this, but I cannot find it document too well, or I always run into problems. So here I hope this to be a good reference to me. Also there could be other/better ways of doing something similar that I am not aware of.
Just revisiting this: I have a repo that I just pushed to github with a master branch that looks something like:
$ ls
assets index.html README.md robots.txt
Now I want to publish it on github. I was about to follow this from my notes
git branch gh-pages
git push origin gh-pages
git branch
git checkout gh-pages
git status
git branch
touch .nojekyll
ls -a
git add .nojekyll
git commit -a -m "adding .nojekyll file"
git remote -v
git push origin gh-pages
But I just done the following: and went to settings of my repo and it said Your site is published at ...
. so maybe this is all I need to do? I will revisit again...
git branch gh-pages
git push origin gh-pages
git branch
git checkout gh-pages
Upvotes: 0
Views: 521
Reputation: 3440
You should check the gh-pages
, it gives step by step documentation
git clone repo.git
cd repo
git branch --orphan gh-pages
add your html/css/js files ...than commit and push.
git push origin gh-pages
Upvotes: 1