This post is dedicated to the use-case where there are 2 different branches in a project.
Typically one branch is for the source files, and one is for the generated output files for publishing.
This use-case matches the way in which this website is currently hosted, via GitHub pages.
master branch is eventually published, whereas other branches remain in the repositories only.
Typically generated websites have a dedicated distribution directory like
Just some prepwork is needed to get this working.
We have two seperate branches, one for the source files
src, and one for the generated output for publishing
As there is little to no correlation between both branches, the
--orphan option can be used during the
git checkout to prevent branches from forcefully bing associated with each other.
$ git branch -a master * src remotes/origin/master remotes/origin/src
Part of the trick is not to ignore the output
.html files in the
src branch, to make it available for the git commands.
.adoc files can be ignored from out of the
master branch, but that is mainly to reduce the effect of those oops moments.
To successfully generate the output files and have them end up in the
master branch we need to do a little dance.
The actual transfer is being done via
If you are unexperienced with Git, just know you can always run
$ git checkout src
$ make html asciidoctor index.adoc asciidoctor posts/index.adoc asciidoctor posts/2016-08-02-static-site-with-separate-source-branch.adoc
$ git add *.html **/*.html
$ git stash
$ git checkout master
$ git rm *.html **/*.html
$ git stash pop
The new and modified files are automatically added as staged in git, so making a commit will do.
$ git commit -m "chore: site update"
If your use-case covers more or different files than the HTML files in this example, then replace the