Take the 2-minute tour ×

I have a pre-receive hook on a remote bare Git repo that will run tests, compress some files and generate a build ID when I do from my laptop:

 $ git push production master

The simplified version of the pre-receive hook is something likje this:

while read oldrev newrev refname
# Export deployed branch to build directory
mkdir -p $BUILD_DIR
git archive $newrev | tar -x -C $BUILD_DIR 

Now, I've added two submodules to the repo, and I can't find any documentation or example about how to handle this. I know that I should run before the build script:

# git submodule init
# git submodule update

But, as far as I know, that will get the submodules referred by the old revision code and not the ones referenced in the new pushed code still not committed to the remote repo.

Any idea or example on how to handle this?

Thanks a lot.

share|improve this question
add comment

1 Answer

Ok, I've found a solution that (for now) seems to be working, something like this solved it:

echo "Exporting repo and submodules for build process..."
git clone -l --recursive . $BUILD_DIR  
echo "Cleaning up git information..."
find $BUILD_DIR -name ".git" -exec rm -rf {} \; || true

Until I find a cleaner way to do it...this will do :-)

share|improve this answer
add comment

Your Answer


