Document Home | Document Index


 Git archive with submodules

This script is adapted from https://ttboj.wordpress.com/2015/07/23/git-archive-with-submodules-and-tar-magic/

This works, but really should be cleaned and generalised.

RESULT=../halibut-temp.tar
git archive --prefix=halibut-temp/ -o $RESULT HEAD

p=`pwd` && (echo .; git submodule foreach) | while read entering path; do \
    temp="${path%\'}"; \
    temp="${temp#\'}"; \
    path=$temp; \
    [ "$path" = "" ] && continue; \
    (cd $path && \
        git archive --prefix=halibut-temp/$path/ HEAD > $p/tmp.tar && \
        tar --concatenate --file=$p/$RESULT $p/tmp.tar && \
        rm $p/tmp.tar); \
done

Document Home | Document Index