Last active
October 2, 2015 17:58
-
-
Save pasela/2290014 to your computer and use it in GitHub Desktop.
git-export - Create an unversioned copy of a tree.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# git-export - Create an unversioned copy of a tree. | |
# | |
# USAGE | |
# git export [<tree-ish>] <path> | |
# | |
# Author: Yuki <[email protected]> | |
# 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