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 echo -en "\nAdding '.empty' files to empty folder(s): ... "; find ${SRC_DIR} -not -path "*/.git/*" -type d -empty -exec touch {}/.empty \; echo "done."; GIT_COMMIT="Including '.empty' files into Git-Index container."; git add .; git ci "${GIT_COMMIT}"; if [ "${?}" -eq 0 ]; then echo " done."; fi /bin/rm -rf ${TRG_DIR} && mkdir -p "${TRG_DIR}"; echo -en "\nChecking-Out Index component(s): ... "; git checkout-index --prefix=${TRG_DIR}/ -q -f -a if [ "${?}" -eq 0 ]; then echo "done."; echo -en "Resetting HEAD and Index: ... "; git reset --soft HEAD^; if [ "${?}" -eq 0 ]; then echo "done."; echo -en "Purging Git-Specific component(s): ... "; /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 '{}' \; echo -e "done.\n" fi echo -en "Archiving Checked-Out component(s): ... "; if [ -f "${TRG_DIR}.tgz" ]; then /bin/rm ${TRG_DIR}.tgz; fi cd ${TRG_DIR} && tar -czf ${TRG_DIR}.tgz ./; cd ${SRC_DIR} echo "done."; ls -al ${TRG_DIR}.tgz fi git reset HEAD; unset TRG_DIR; unset SRC_DIR; echo ""; return 0; } Usage: git-export /tmp/testing [./ $PWD is optional]
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.