tags:

views:

174

answers:

3

github has this feature where you can publish "Project Pages" if you create a new branch gh-pages in your project. For full description see http://pages.github.com/

My project is just html/images, so I just want to serve the master branch.

so how do I create a new branch called gh-pages that is just exact copy of master? some kind of link operation?

Thanks

A: 

Create a local clone of your repository, create a new local branch called gh_pages, then push that new local branch to your repository, on the branch gh_pages

git clone [email protected]:<username>/<project>.git
cd <project>
git checkout -b gh_pages
git push origin gh_pages
swillden
This works perfectly but there's a typo. It's gh-pages instead of gh_pages.
maxhawkins
+1  A: 

That's actually the default behavior of the git branch command. The more complicated symbolic-ref and clean commands you see listed in the "pages" writeup are needed to avoid doing exactly this.

So, at your project root, on the master branch:

git branch gh-pages
git checkout gh-pages

Or just:

git checkout -b gh-pages
Ash Wilson
so if i update master, gh-pages will reflect the updates? and if i add some files to gh-pages, will it still get updates from master?
git
Not automatically, no; you'll have to use `git merge` to move changes and files from branch to branch.See http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html#_managing_branches for a good explanation of how branches are used.
Ash Wilson
Ok thats what I thought, thanks a bunch.
git
+1  A: 

You want branch 'hg_pages' in your GitHub repository to be the same as 'master' branch. The simplest solution would be to configure git to push branch 'master' to 'hg_pages' automatically.

Assuming that your GitHub repository you push into is configured as 'origin' remote, you can somply do:

$ git config --add remote.origin.push +refs/heads/master:refs/heads/gh_pages

Or if you prefer you can simply edit .git/config file directly.

Then when you do git push or git push origin you would push 'master' branch in your repository into 'gh_pages' branch into repository on GitHub.

See git-push manpage for documentation and description of refspec format.

Jakub Narębski
You meant 'gh-pages' I presume not 'hg_pages'
nowarninglabel