Bash-implementation of git-export. Since everyone has this un-controllable hunger to show-off, I just wanted to join the gang. Hope you find it of use. It works perfectly fine.
function git-export () { TRG_DIR="${1}"; SRC_DIR="${2}"; if [ -z "${SRC_DIR}" ]; then SRC_DIR="${PWD}"; fi find ${SRC_DIR} -not -path "*/.git/*" -type d -empty -exec touch {}/.empty \; git add . && git commit -q -m "Including '.empty' files into Git-Index container."; /bin/rm -rf ${TRG_DIR} && mkdir -p "${TRG_DIR}"; git checkout-index --prefix=${TRG_DIR}/ -q -f -a if [ "${?}" -eq 0 ]; then git reset -q --mixed HEAD^; if [ "${?}" -eq 0 ]; then /bin/rm -f ${TRG_DIR}/.git* find ${TRG_DIR} -type f -name .empty -exec /bin/rm '{}' \; find ${SRC_DIR} -type f -name .empty -exec /bin/rm '{}' \; fi if [ -f "${TRG_DIR}.tgz" ]; then /bin/rm ${TRG_DIR}.tgz; fi cd ${TRG_DIR} && tar -czf ${TRG_DIR}.tgz ./; cd ${SRC_DIR} ls -al ${TRG_DIR}.tgz fi unset TRG_DIR; unset SRC_DIR; return 0; } Usage: git-export /tmp/testing ./
Note: Including an archive file *.tgz to this function. The problem with this function is that it does causes havoc if applied to a git-tag. Have to implement a portion of it to determine if the source if a tag and then not do a $(git reset --mixed HEAD^) which leaves the tag corrupted.