Automatically publish markdown files in git repo to webserver

I have a git repo that has a docs directory where I keep markdown files that document things I’m working on (for example, I have one called setup_git_server.mdown). I push and pull the repository (and others) from my own webserver running gitolite.

What I want to happen is that whenever I push a commit to the server, it automatically converts the markdown files to HTML and copies them to a directory on the server where Apache can server them.

  • GIT vs. Perforce- Two VCS will enter… one will leave
  • git: I got “am/rebase” in my prompt, what to do?
  • Strange behavior from git log --since
  • How to mirror my source code that is in SVN repository with git
  • Interactive rebase without editor
  • .gitignore exclude folder but include specific subfolder
  • What’s the best way to do this?

  • Git fast-forward merge : why “fast”
  • With “git svn”, Can I Ignore Specific Git Commits While Fetching?
  • Git says local branch is behind remote branch, but it's not
  • How to update repository location in Git Tower
  • How does git know which commit to check a submodule out at?
  • Git merge failed to bring over some files
  • 2 Solutions collect form web for “Automatically publish markdown files in git repo to webserver”

    You will want to setup a git hook on the server your repository is hosted. A hook will only run on the machine where it is installed. The hooks themselves are not part of the checked in code base. For example, any post commit hooks you have on your local machine will not be pushed or executed on the server. Other people who check our your code base will not get your hooks.

    If you want the server to take an action when it receives a push, you should create a post-receive hook. The hook can be any executable. In your case, you may want to clone your repo to a temp directory, extract the markdown file, and publish it to your web server.

    I’m not sure if it’s the same for gitolite, but in gitosis, the hooks directory is in the top level of each hosted repository. Place your post-receive hook in that directory.

    Look in your .git directory for a subdirectory named “hooks”. You’ll find sample shell scripts in there that respond to various events. Choose one, e.g. post-commit and tune it to update your documents.

    See git hooks and how they work or just Google for “git hooks”

    Git Baby is a git and github fan, let's start git clone.