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
If thats the case, the safest option is to merge your master branch into the gh-pages branch (assuming you dont have other files on master you would rather not have on the gh-pages branch). The command suggested git push -f origin master:gh-pages will push your local master branch to the gh-pages branch.
follow the steps below to setup your projects folders on your local system. Open Terminal. app, create project parent folder ("grandmaster"), and a subfolder for the "master" branch. Initialise a new git repository for the project and push the "master" branch to GitHub.
In the command line, go to the root directory where your local files are. Optionally initialize the local directory (git init). Add the your file changes (git add) and commit your changes (git commit). Finally, push your changes of the local file or repository to GitHub (git push).
You want branch 'gh-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 'gh-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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With