tags:

views:

338

answers:

1

I have tried:

git archive HEAD --format=zip > archive.zip

:and then I email archive.zip and at the other end they unzip archive.zip into a folder. But when they try any git commands they find out that this does not produce a valid git repository

+14  A: 

You could use git bundle and email one single file

See "backing up project which uses git"

A git bundle is just one file which can be very easily created and again imported as it can be treated like another remote.

Once received, you can clone it or fetch from that file.

As mentioned in "Backup of github repo", you will probably want for the first email to make your bundle with all branches:

$ git bundle create /tmp/foo-all --all

As Andreas mentions in the comments, Scott Chacon recently (March 2010) wrote a "cute" article on this topic in the ProGit blog:

Git's Little Bundle of Joy

VonC
Thanks. I read this but it wasn't clear if all my history and branches are saved. Also does it allow me to merge both repositories at a later date?
Zubair
@Zubair: yes, all the history is saved, contrary to `git archive`!
VonC
Now I can't unbundle it!!! Don't worry, I'm hunting around the docs as we speak
Zubair
Thanks. I figured it out:git init, and then :git pull bundle.bdl master
Zubair
@Zubair: unbundle it? You can simply clone it to get back a normal git repo. Or pull it in an empty repo. Which is, I see now, what you did ;)
VonC
I was trying "git bundle unbundle bundle.bdl" which seemed the sensible thing to do. Anyway, it works now, thanks! :)
Zubair
This is a good overview of how to use the bundle command and what it does: http://progit.org/2010/03/10/bundles.html
Andreas