I\'ve been wondering whether there is a good \"git export\" solution that creates a copy of a tree without the .git
repository directory. There are at least thr
I needed this for a deploy script and I couldn't use any of the above mentioned approaches. Instead I figured out a different solution:
#!/bin/sh
[ $# -eq 2 ] || echo "USAGE $0 REPOSITORY DESTINATION" && exit 1
REPOSITORY=$1
DESTINATION=$2
TMPNAME="/tmp/$(basename $REPOSITORY).$$"
git clone $REPOSITORY $TMPNAME
rm -rf $TMPNAME/.git
mkdir -p $DESTINATION
cp -r $TMPNAME/* $DESTINATION
rm -rf $TMPNAME
As simple as clone then delete the .git folder:
git clone url_of_your_repo path_to_export && rm -rf path_to_export/.git
git archive
also works with remote repository.
git archive --format=tar \
--remote=ssh://remote_server/remote_repository master | tar -xf -
To export particular path inside the repo add as many paths as you wish as last argument to git, e.g.:
git archive --format=tar \
--remote=ssh://remote_server/remote_repository master path1/ path2/ | tar -xv
Yes, this is a clean and neat command to archive your code without any git inclusion in the archive and is good to pass around without worrying about any git commit history.
git archive --format zip --output /full/path/to/zipfile.zip master
The equivalent of
svn export . otherpath
inside an existing repo is
git archive branchname | (cd otherpath; tar x)
The equivalent of
svn export url otherpath
is
git archive --remote=url branchname | (cd otherpath; tar x)
This will copy all contents, minus the .dot files. I use this to export git cloned projects into my web app's git repo without the .git stuff.
cp -R ./path-to-git-repo /path/to/destination/
Plain old bash works just great :)