Linux – Exporting Files From Git (similar to SVN export)

I use git for just about all my code now. For some of my work, I need to export portions of or all of a git repo into some other location without picking up all the git files themselves. This is the way svn export works. There are two ways I do this. One is using git archive. This command always returns a zipped up copy of the repository, so you have to pipe it over to tar if you want to export files (either that or save the tar file and then in a second command extract it). Here’s my one-line command for taking the archive and sending it to a different location:

git archive HEAD | (cd ~/path/where/I/want/it/ && tar -xvf -)

This will extract the ENTIRE library to the specified path (without the .git files and whatnot).

Sometimes, however, I want to pull out just a portion of the library. git archive always gives you the whole enchilada which kinda sucks, and in this case I use rsync, like this:

rsync path/I/want/to/export/ -ri --del -m --exclude ".*" ~/path/where/I/want/it/ |grep sT

That last bit – the grep sT will limit the output of what I see so that I only see the files that are updated. I use that just to sanity check my export. If I see a TON of stuff go to update a path that already has the library and I know I only changed one file, then I know I got the path wrong.

2 Replies to “Linux – Exporting Files From Git (similar to SVN export)”

  1. Pingback: Tweets that mention Linux - Exporting Files From Git (similar to SVN export) | WhileIf Blog -- Topsy.com

  2. Pingback: Linux – Exporting Files From Git (similar to SVN export)

Leave a Reply

Your email address will not be published. Required fields are marked *

*