rsync out of git repository or tar archive -


i have git repository , want rsync particular revision of repository directory. want this:

$ cd my-git-repo $ git archive $my_commit > ~/blah.tar.gz $ mkdir ~/tmp $ cd ~/tmp $ tar xf ~/blah.tar.gz $ rsync -a ~/tmp/ ~/final-destination $ cd $ rm -r tmp 

the problem requires extracting temporary directory , rsyncing that. (theoretically) unnecessary , huge git repository takes long time , requires lot of free space. don't want clear ~/final-destination , tar directly with:

$ git archive $my_commit | tar x -c ~/final-destination 

because requires lot of unnecessary work if ~/final-destination remote directory. option checkout particular revision , rsync directly out of repository:

$ git checkout $my_commit $ rsync -a --exclude .git my-git-repo/ ~/final-destination 

but i'd rather not mess repository's working directory. want in script may run in background while i'm doing stuff in respository.

so. there way rsync directly out of particular revision of repository. or failing can somehow rsync tar archive without having extract it?

if don't want rsync out of working tree, i'm afraid you're stuck extracting temporary directory first. (although when kind of thing on stack overflow, inevitably comes more ingenious :))

one thing try stash changes, checkout commit want, rsync, switch previous branch pop stash again:

set -e  git stash git checkout $my_commit rsync -a --exclude .git ./ ~/final-destination git checkout - git stash pop 

(i haven't tested that, should warn you.)


Comments