This seems like a simple thing, but cannot find the solution online. First, I know I can probably do this on the Terminal, but I would prefer to do this with Tower. Not all of my colleagues will use the Terminal. I have a repository (https://github.com/jbryer/psabook/) and I would like to use Github pages with it. I want the master branch to track the source (mostly markdown files). I build a website from those files and would like to publish that to the gh-pages branch. Can I have that as a subdirectory of my repository be tracked only for that branch?
Here's what I have tried from this post: http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html
I create a repository called psabook from Github.com. Then do the following from the command line (on a Mac if it matters):
git add README
git commit -m "initial commit"
git remote add origin firstname.lastname@example.org:jbryer/psabook.git
git push origin master
git symbolic-ref HEAD refs/heads/gh-pages
git clean -fdx
echo "Hello PSA Book" > index.html
git add .
git commit -a -m "first gh-page"
git push origin gh-pages
git checkout master
git submodule add -b gh-pages email@example.com:jbryer/psabook.git _site
Cloning into '_site'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 6 (delta 0)
Receiving objects: 100% (6/6), done.
Checking connectivity... done.
On branc master
Changes to be committed:
(use "git reset HEADE <file>..." to unstage)
new file: .gitmodules
new file: _site
git commit -m "added gh-pages as submodule"
git submodule init
error: pathspec 'Submodule' did not match any file(s) known to git.
error: pathspec '(firstname.lastname@example.org:jbryer/psabook.git)' did not match any file(s) known to git.
error: pathspec 'registered' did not match any file(s) known to git.
error: pathspec 'for' did not match any file(s) known to git.
error: pathspec 'path' did not match any file(s) known to git.
Did you forget to 'git add'?
You can see both content (
gh-branch) from the
You would need for that to declare your
gh-branch as a submodule(!) in your
That way, when you are in your
master branch, the
gh-branch is displayed as a sub-folder.
Once that setup is done (in command line), you can manage everything from Tower.
See "What's the easiest way to deploy a folder to a branch in git?" for the submodule setup.
Each modification in
gh-branch would then need to be committed, and you would need to go back in the main folder to commit (again), in order to record the gitlink (special entry mode 160000).
That way, each version of the
master branch knows which version of the
gh-branch it is supposed to work with.
Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more
So this is easier now: now need for two branches, you can do everything in one.