Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").
Author: Chris Jacob @_chrisjacob
Tutorial (Gist): https://gist.github.com/833223
The final folder structure on my local system is:
/grandmaster
/grandmaster/master
/grandmaster/master/.git # checkout of "master" branch
/grandmaster/master/README.markdown
/grandmaster/gh-pages
/grandmaster/gh-pages/.git # checkout of "gh-pages" branch (removed "master" branch)
/grandmaster/gh-pages/index.html
/grandmaster/gh-pages/README.textile
See "master" branch: https://github.com/chrisjacob/grandmaster
See "gh-pages" branch: https://github.com/chrisjacob/grandmaster/tree/gh-pages
See GitHub Page (auto generated): http://chrisjacob.github.com/grandmaster/
A note for GitHub novices - replace "Amourspirit" with your own GitHub username.
A note for Terminal novices - you don't need to enter the "ichris:Sites $ " parts of the code listed below. ^_^
Visit GitHub and create a new repository with the project name "grandmaster".
https://github.com/repositories/new
Don't follow GitHub's
Next steps
instructions! 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.
1. ichris:Sites $ mkdir grandmaster
2. ichris:Sites $ cd grandmaster/
3. ichris:grandmaster $ mkdir master
4. ichris:grandmaster $ cd master/
5. ichris:master $ git init
6. ichris:master $ echo "# Master README file" > README.markdown
7. ichris:master $ git add .
8. ichris:master $ git commit -m "Master README added"
9. ichris:master $ git remote add origin https://github.com/Amourspirit/grandmaster.git
10. ichris:master $ git push origin master
Refresh your projects "master" branch page on GitHub to see the committed files.
https://github.com/Amourspirit/grandmaster
Auto generate a GitHub Pages branch, with some default content.
https://github.com/Amourspirit/grandmaster/generated_pages/new
Or follow these steps to get to the generator page:
Go to the projects Admin page on GitHub https://github.com/Amourspirit/grandmaster/admin
Check the "GitHub Pages" checkbox
A popup will ask you to "Activate GitHub Pages" - click the big "Automatic GitHub Page Generator" button
Check that your GitHub Pages page has been built and is available.
http://Amourspirit.github.com/grandmaster/
Back in Terminal.app, change directory back to the parent folder, setup a "gh-pages" subfolder for your "gh-pages" branch and change directory into it.
11. ichris:master $ cd ../
12. ichris:grandmaster $ mkdir gh-pages
13. ichris:grandmaster $ cd gh-pages/
Clone your "grandmaster" repository into the "gh-pages" folder (this will clone in the "master" branch), checkout the "gh-pages" branch, list the files (should have "index.html" and ".git") and then remove the "master" branch to avoid any confusion. Last step is to check that "master" branch was removed and only "gh-pages" branch is listed.
Important Make sure to include the dot (.) at the end of line 14 to ensure that git clones into the gh-pages folder and not into a grandmaster subfolder
14. ichris:gh-pages $ git clone https://github.com/Amourspirit/grandmaster.git .
15. ichris:gh-pages $ git checkout origin/gh-pages -b gh-pages
16. ichris:gh-pages $ ls -la
17. ichris:gh-pages $ git branch -d master
18. ichris:gh-pages $ git branch
You will probably get a warning when deleting the "master" branch... don't worry about it ^_^
Lets add a "README.textile" file to the "gh-pages" branch
19. ichris:gh-pages $ echo "h1. GitHub Pages README file" > README.textile
20. ichris:gh-pages $ git add .
20. ichris:gh-pages $ git commit -m "Child README added"
Now push to the "gh-pages" branch
21. ichris:gh-pages $ git push origin gh-pages
Visit your projects "gh-pages" branch page on GitHub to see the committed files.
https://github.com/Amourspirit/grandmaster/tree/gh-pages
If everything has gone well you now have a parent project folder named "grandmaster", with subfolders for its two branches "master" and "gh-pages"; each containing a checkout of their respective branch.
For me this system keeps things nice and tidy without needing to do
git checkout gh-pages
each time I want to view my "gh-pages" branch.Might also be a useful structure for output from static site generators like Jekyll, Webby, or nanoc.
Enjoy ^_^