Skip to content

Instantly share code, notes, and snippets.

@pasela
Last active October 2, 2015 17:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasela/2290014 to your computer and use it in GitHub Desktop.
Save pasela/2290014 to your computer and use it in GitHub Desktop.
git-export - Create an unversioned copy of a tree.
#!/bin/sh
#
# git-export - Create an unversioned copy of a tree.
#
# USAGE
# git export [<tree-ish>] <path>
#
# Author: Yuki <paselan@gmail.com>
# License: MIT License
#
if [ $# -eq 2 ]; then
TREE_ISH=$1
DEST_DIR=$2
elif [ $# -eq 1 ]; then
TREE_ISH=HEAD
DEST_DIR=$1
else
echo -e "usage: git export [<tree-ish>] <path>\n" 1>&2
exit 1
fi
if [ ! -d "$DEST_DIR" ]; then
mkdir -p $DEST_DIR || exit 1
fi
#echo DESTDIR=$DEST_DIR
#echo TREE_ISH=$TREE_ISH
git archive --format=tar $TREE_ISH | tar -C $DEST_DIR -xf -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment