如何通过电子邮件向某人发送 git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2545765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:10:18  来源:igfitidea点击:

How can I email someone a git repository?

git

提问by Yazz.com

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

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

回答by VonC

You could use git bundleand email one single file

您可以使用git bundle并通过电子邮件发送一个文件

See "backing up project which uses git"

请参阅“备份使用 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.

git bundle 只是一个文件,可以很容易地创建并再次导入,因为它可以被视为另一个远程文件。

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 allbranches:

如“ github repo 的备份” 中所述,您可能希望第一封电子邮件将您的所有分支打包:

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

As Andreasmentions in the comments, Scott Chaconrecently (March 2010) wrote a "cute" article on this topic in the ProGit blog:

正如Andreas在评论中提到的,Scott Chacon最近(2010 年 3 月)在ProGit 博客中写了一篇关于这个主题的“可爱”文章:

Git's Little Bundle of Joy

Git 的快乐小包

回答by Manu Manjunath

As previous answer said, git bundleis the way.

正如之前的回答所说,git bundle就是这样。

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

如果您想仅使用一个分支(我更喜欢仅捆绑主分支)并通过电子邮件发送来创建捆绑包,您可以执行以下操作:

$ git bundle create /tmp/mygitbackup.bundle master

$ git bundle create /tmp/mygitbackup.bundle master