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

标签 linux git email github sendmail

我在本地创建了一个目录:/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
  1. 现在我想先使用 git send-email 向电子邮件地址 abc@xyz.org. 发送一封电子邮件,其中应包含 hello_world。 c文件

  2. 然后我想发送第二封电子邮件,附件是 hello_world_1.patch 文件。

  3. 然后我想发送第三封电子邮件,附件是 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 步:根据下面的评论,我们需要一个存储库:

  1. 在 Github 上创建了一个空的存储库:“MyRepo”
  2. 在本地机器上克隆它。 (使用 git clone )
  3. 然后将第一个文件“hello_world.c”添加到目录/MyRepo 中。
  4. 然后 >>git add hello_world.c
  5. 然后 >>git commit -m 'My First source'
  6. 然后 >>git push -u origin master
  7. 之后,我输入: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 仓库。

关于linux - 无法使用git send-email发送源码和补丁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33016965/

相关文章:

linux - 删除数字后逗号前的字母

linux - 同一网络中的2个Weblogic集群

php - 在 Amazon EC2 Linux AMI 上安装 FFMPEG-Php

git - Git merge --squash 可以保留提交注释吗?

git - 我怎样才能只应用一些 git stash?

git - 将目录拆分为子模块

android - 如何在不打开gmail撰写页面的情况下直接通过gmail发送邮件

c - 出现错误 "In function ' _start' : (. text+0x20): 对 `main' 的 undefined reference “无法使用类似问题的答案来解决

email - 我是否最好使用 Google Mail 服务器来确保我的电子邮件不会被标记为垃圾邮件?

c# - 有没有办法在 C# 应用程序中保持电子邮件 session ?