Skip to content

Instantly share code, notes, and snippets.

@clly
Created July 9, 2012 02:15
Show Gist options
  • Save clly/3073845 to your computer and use it in GitHub Desktop.
Save clly/3073845 to your computer and use it in GitHub Desktop.
Get git repository without the .git directory in specified folder
#!/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