Failed to use git send-email to send source code and patches

I have a local directory: /home/Tegra.

I created the following files inside / home / Tegra:

 hello_world.c hello_world_1.c hello_world_2.c 

Each file changes in stages. I also created patches like:

 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 
  • Now I want to first send an email with a git address to an email address abc@xyz.org. , which should contain a hello_world.c file

  • Then I want to send a second letter with the file hello_world_1.patch as an attachment.

  • Then I want to send a third email with the hello_world_2.patch file as an attachment.

Unfortunately, I cannot even complete step 1:

My git was configured correctly with the corresponding smtp server tls 587 port.

I tried the following command:

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

I get the following error:

 Cannot run git format-patch from outside a repository 

Where is the repository located? Do I have to save my code repository first.

Edit: for step 1: according to the comments below we need a repository:

  • Created an empty repository on Github: "MyRepo"
  • Cloning it on a local machine. (using git clone)
  • Then the first file "hello_world.c" is added to the / MyRepo directory.
  • Then -> git add hello_world.c
  • Then -> git commit -m "My first source"
  • Then -> git push -u origin master
  • After that I typed: git send-email --to=abc@xyz.org --subject = "[asdasdas] assd asdasd" hello_world.c

Now I get the error message:

 No subject line in hello_world.c ? at /usr/lib/git-core/git-send-email line 584 
+5
source share
1 answer

Then the first file "hello_world.c" is added to the / MyRepo directory.

First, make sure you really accomplish anything in your cloned empty repo.

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

Secondly, git send-email doc mentions:

 --subject=<string> 

Indicate the starting email subject. Only needed if --compose also installed .

Be sure to use --compose .

This format expects the first line of the file to contain the β€œ Cc: ” and β€œ Subject: ” message values ​​as the second line.

This will work with .patch , not the source itself.
See git format-patch and How to send patches using git-send-email "for a more complete example:

For the last commit:

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

Third, a simpler solution would be to use git bundle . This creates a single file that you can send in any way and from which the recipient can extract / clone. It acts (single file) as an open git repository.

+1
source

Source: https://habr.com/ru/post/1233245/


All Articles