Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I got a GIT repository with a couple of submodules. Now i created a "post-update" hook on my webserver that automatically deploys my website on update.

That's how my post-update hook looks like:

#!/bin/sh
rm -rf /home/my_user/public_html/my_website/*
unset GIT_INDEX_FILE
export GIT_WORK_TREE=/home/my_user/public_html/my_website/
export GIT_DIR=/home/my_user/gitrepos/my_website.git
git checkout -f

Everything works nicely apart from the fact that the submodules directories are not exported... And that is my question. How can I deploy a GIT repository and it's submodules through the post-update hook?

Thanks in advance!

share|improve this question

2 Answers 2

It should work, except you could add, for taking care of those submodules:

git submodule init
git submodule update

See also Using git submodule update --init on a post hook if you have error messages.

share|improve this answer
up vote 1 down vote accepted

Alright I made a script that avoids the use of a non-bare repository and receive.denyCurrentBranch ignore

#!/bin/sh

# DIR VARS
DIR_GIT="/home/my_user/gitrepos/my_repo.git"
DIR_HTTP="/home/my_user/public_html/my_website"

unset GIT_DIR

# Recreate HTTP dir
rm -rf $DIR_HTTP
mkdir $DIR_HTTP

# Clone git repository
git clone $DIR_GIT $DIR_HTTP

# import submodules
cd $DIR_HTTP
git init --bare $DIR_HTTP
git submodule init
git submodule update

# delete unnecessary git repository in http dir
rm -rf $DIR_HTTP/.git

Any improvements are welcome

share|improve this answer
    
Nice feedback, more practical than my own answer. +1 –  VonC Jan 3 '13 at 19:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.