Version Control Data into Latex Document

For a while I have been writing most of my documents in a combination of Org-Mode and Latex and keeping the folders under Git version control.

In a near perfect example of procrastination I decided to integrate the version control information into the Latex export.

Most of the hard work was already done as CTAN has the VC package which provides the integration between git log messages and moving them into the latex document.

I added to this so that the package can be used in a folder with the document and also a very basic template so that VC info is place on its own page.

In typical scratching your own itch fashion it only works with Git repos.

The code is on github at https://github.com/scotthewitt/vc-reporting

and the once cloned into the working directory can be used by including,

\input{vc-reporting/revisioninfo.tex}

at the desired location.

Git Submodule

Found this online today.

git submodule foreach ‘git fetch origin –tags; git checkout master; git pull’ && git pull && git submodule update –init –recursive

It makes working with submodules in git really easy and it works with submodules within submodules.

Awesome.

Web Publishing with Git

So as I have been increasing movingly my life into Git version control it made sense to explore methods of publishing with Git.

Turns out to be quiet simple.

On the web server

Create a folder to host live site (live)

mkdir live

Create a folder to host git repository (repo)

mkdir repo

Create git bare repository in folder (repo)

cd repo
git init --bare

Within the hooks folder create a file called post-receive

nano hooks/post-receive

with the following text

#! /bin/sh
GIT_WORK_TREE="../live" git checkout -f

Now ensure the folder live is writable by the web server and that the file post-receive is executable. This hooks means that when the repository is committed to it will check out the files to the live web directory.

On the local box

Now on the box that the files exisit all you need to do is add a new remote (I tend to call it web but it can be called anything).

git remote add web *your-remote-url*

and then when you push the files will be made live.