Git and dropbox

This blog is in a git repository and I push it to a remote repository on my server. That means I can always go back to a previous version, even if my computer breaks. Even so, I like the idea of having a backup.

Backing up a git-repository to Dropbox

Git and Dropbox don’t play together nicely so I don’t have my git-repositories in Dropbox. Instead I create a zip-file to the Dropbox each time I commit something.

The nice thing is that Git makes this really easy! Just create a post-commit file in the .git/hooks directory, make it executable (chmod +x post-commit) and add the following:


echo "Running post-commit"
d=`date -j "+%Y%m%d_%H-%M-%S"`
exec git archive -o "/Users/username/Dropbox (Personal)/your-backup-folder/"$ head

This creates zip-files with the filename of the current date/time (



Looking forward to hearing other people’s ideas on this!