Created
July 9, 2012 02:15
-
-
Save clly/3073845 to your computer and use it in GitHub Desktop.
Get git repository without the .git directory in specified folder
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 | |
####### | |
# Change for actual use | |
####### | |
USER="example" | |
FINAL_LOCATION = "/tmp" | |
PREFIX = "junk/" | |
####### | |
# ensures repository is specified | |
####### | |
if [ "$1" == "" ] | |
then | |
echo "Usage; getRepo.sh <repository>" | |
exit 1 | |
fi | |
echo "git clone http://github.com/'$USER'/'$1'.git" | |
git clone http://github.com/$USER/$1.git | |
repo=$(pwd) | |
echo "Moving to $repo" | |
## Moves repository to specified directory and extracts it | |
git archive --format=tar --prefix=$PREFIX HEAD | (cd $FINAL_LOCATION && tar xf -) | |
cd $repo/.. | |
echo "Deleting temp files..." | |
rm -Rf $repo | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment