From charlesreid1

To use git for static content deployment:

  • Use the gh-pages branch to hold all of the web content
  • Use the master or source branch to hold the files needed to generate the static content

New Deployment

When you have content on your gh-pages branch, deploy it on your live machine using the following git clone command:

git -C /www/example.com clone --separate-git-dir=git -b gh-pages <git-repo-url> htdocs

This will create the following directory structure:

/www/example.com/
        htdocs/
            index.html
            ...
        git/
            ...

This keeps your .git out of your htdocs directory.

I also like to clone a copy of the source next to htdocs and git, so that /www/example.com/example.com-src is a copy of the master or source branch.

Pulling Existing Deployment

Once you've updated content on the gh-pages branch, you can run git pull in the same manner as the git clone command above (that is, specifying a different git and working directory). However, the syntax looks different:

git -C /www/example.com --git-dir=git --work-tree=htdocs pull origin gh-pages

Webhooks

You can add these to webhook scripts, as with Captain Hook.

Flags