我怎样才能给某人发送 git 存储库的电子邮件?

我试过了:

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

然后我发邮件给 Archive.zip,在另一端,他们把 Archive.zip 解压缩到一个文件夹中。但是当他们尝试任何 git 命令时,他们发现这不会产生一个有效的 git 存储库

31388 次浏览

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

As previous answer said, git bundle is the way.

If you want to create a bundle from using only one branch (I prefer bundling only main) and sending over e-mail, you can do something as below:

git bundle create ~/mygitbackup.bundle main

Above will create a git bundle file in your home directory.