When it comes to GitHub pages , you have user pages and project pages.
I assume that you are talking about the latter, which means that you need to create your own gh-pages
branch, copy the documentation files from the master
branch to this new empty branch, as described on the GitHub document page.
From there, when you have new commits in both your master
and gh-pages
branches, you can push both branches with one click ( git push --all
)
Problems begin when you absolutely want to see both directory structures at the same time.
The simplest solution:
- one clone of your repo is installed in the
master
branches. - one clone (of the same repo) on branches of gh-pages.
- symbolic link from the first repo to the second repo (which allows you to make changes to the code and the document in the same directory structure. Symbols are even supported on Windows with Vista).
- a git alias script to automate the command sequence '
git push master origin; cd ../secondRepo; git push gh-pages origin
git push master origin; cd ../secondRepo; git push gh-pages origin
git push master origin; cd ../secondRepo; git push gh-pages origin
'
You can try to get the doc repository as a submodule of your main repo, but ... it looks more complicated than it should: see " How to add git repo as a submodule? (Or: how to programmatically create GitHub pages?) ".
August 2016 Update: Simplified Publishing GitHub Pages now allows you to store your page files in subfolders (no more than gh-pages
):

Finally, you can update both codes and pages in the same branch.
source share