Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created October 14, 2012 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/3886937 to your computer and use it in GitHub Desktop.
Save ramnathv/3886937 to your computer and use it in GitHub Desktop.
Pushing Documentation to Github Pages
# ignore built md and html files in the slides directory
slides/*.html
slides/*.md
slides/fig/*
slides/figures/*
# Makefile
GITHUB_REPO ?= yourname/project
# Sends the documentation to gh-pages.
docs.deploy: docs
cd docs && \
git init . && \
git add . && \
git commit -m "Update documentation."; \
git push "git@github.com:$(GITHUB_REPO).git" master:gh-pages --force && \
rm -rf .git
.PHONY: docs.deploy
@ramnathv
Copy link
Author

I think this makefile finally clarifies what I had been suspecting all along about how to deploy generated files to github without committing it to the repo. Here is what the makefile does.

  1. Change to the docs directory.
  2. Initialize a git repo.
  3. Add all files to the repo.
  4. Commit files to the repo.
  5. Push master branch to remote gh-pages forcefully.
  6. Remove the .git direcotry

@ramnathv
Copy link
Author

I can put all generated files in .gitignore. Some prime candidates are the fig or figure directory in which knitr generated figures are stored.

@ramnathv
Copy link
Author

I tried this and it works. Basically it works by initializing the deploy directory as a git repository, pushing it to a remote gh-pages branch (by force) and removing the .git directory so that all history is erased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment