A CI server can do it for you, but a simple script can also do the trick. David Gageot introduced an very easy solution for private building with git on his blog awhile ago (the idea is to build with the tests on a secondary local repo before pushing on the remote server) :
http://blog.javabien.net/tag/git/page/2/
Unfortunately, it is written in french, but you can still have a look on the script that is used to do it :
#!/bin/bash
if [ 0 -eq `git remote -v | grep -c push` ]; then
REMOTE_REPO=`git remote -v | sed 's/origin//'`
else
REMOTE_REPO=`git remote -v | grep "(push)" | sed 's/origin//' | sed 's/(push)//'`
fi
if [ ! -z "$1" ]; then
git add .
git commit -a -m "$1"
fi
git pull
if [ ! -d ".privatebuild" ]; then
git clone . .privatebuild
fi
cd .privatebuild
git clean -df
git pull
if [ -e "pom.xml" ]; then
mvn clean install
if [ $? -eq 0 ]; then
echo "Publishing to: $REMOTE_REPO"
git push $REMOTE_REPO master
else
echo "Unable to build"
exit $?
fi
fi
EDIT for non java users
In the script above, replace mvn clean install
by the command line allowing you to build your project (and remove the if statement that tests the existance of a maven pom.xml file).