linux – 无法使用git send-email发送源代码和补丁

我在本地创建了一个目录:/ home / Tegra.

我在/ home / Tegra中创建了以下文件:

hello_world.c hello_world_1.c hello_world_2.c

每个文件都是逐步修改的.我还创建了补丁:

diff -u hello_world.c hello_world_1.c > hello_world_1.patch
diff -u hello_world_1.c hello_world_2.c > hello_world_2.patch

>现在我想首先使用git send-email向电子邮件地址abc@xyz.org发送电子邮件.其中应包含hello_world.c文件
>然后我想发送第二封电子邮件,其中包含hello_world_1.patch文件作为附件.
>然后我想发送第三封电子邮件,其中包含hello_world_2.patch文件作为附件.

不幸的是,我甚至无法完成第1步:

我的git已经正确配置了相关的smtp服务器tls 587端口.

我尝试了以下命令:

git send-email --to abc@xyz.org --subject My Hello hello_world.c

我收到以下错误:

Cannot run git format-patch from outside a repository

存储库在哪里出现.我应该首先维护我的代码库.

编辑:对于第1步:根据下面的评论,我们需要一个存储库:

>在Github上创建了一个空存储库:“MyRepo”
>在本地计算机上克隆它. (使用git clone)
>然后将第一个文件“hello_world.c”添加到Directory / MyRepo中.
>然后>> git add hello_world.c
>然后>> git commit -m’我的第一个来源’
>然后>> git push -u origin master
>之后,我输入:git send-email –to = abc@xyz.org –subject =“[asdasdas] assd asdasd”hello_world.c

现在我收到一个错误:

No subject line in hello_world.c ? at /usr/lib/git-core/git-send-email line 584

解决方法

Then added the first file “hello_world.c” into the Directory /MyRepo”.

首先确保您已经在克隆的空仓库中实际提交了任何内容.

git add .
git commit -m "new commit"
git push

其次,git send-email doc确实提到:

--subject=<string>

Specify the initial subject of the email thread. Only necessary if --compose is also set.

一定要使用–compose.

This format expects the first line of the file to contain the “Cc:” value and the “Subject:” of the message as the second line.

这适用于.patch,而不是源本身.
有关更完整的示例,请参见git format-patch和“How to send patches with git-send-email”:

对于最后一次提交:

git send-email -1  --to=abc@xyz.org --subject="[asdasdas] assd asdasd"

第三,一个更简单的解决方案是use git bundle.这会生成一个文件,你可以按照你想要的任何方式发送,接收者可以从中拉出/克隆.它(作为一个文件)作为一个简单的git repo.

相关文章

文章浏览阅读1.8k次,点赞63次,收藏54次。Linux下的目录权限...
文章浏览阅读1.6k次,点赞44次,收藏38次。关于Qt的安装、Wi...
本文介绍了使用shell脚本编写一个 Hello
文章浏览阅读1.5k次,点赞37次,收藏43次。【Linux】初识Lin...
文章浏览阅读3k次,点赞34次,收藏156次。Linux超详细笔记,...
文章浏览阅读6.8k次,点赞109次,收藏114次。【Linux】 Open...