I have a directory created locally: /home/Tegra.
I have created following Files inside /home/Tegra:
hello_world.c hello_world_1.c hello_world_2.c
Each file is incrementally modified. I have also created patches as:
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 using git send-email to email address abc@xyz.org. which should contain hello_world.c file
Then I want to send second email with hello_world_1.patch file as attachment.
Then I want to send third email with hello_world_2.patch file as attachment.
Unfortunately, I am not even able to do the step 1:
My git has been properly configured with relevant smtp server tls 587 port.
I tried following command:
git send-email --to abc@xyz.org --subject My Hello hello_world.c
I get following error:
Cannot run git format-patch from outside a repository
Where does repository come into picture. SHould I have to maintain first a repository of my code.
Edit: For step 1: As per comments below we need a repository:
Now I get an Error:
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".
First make sure you have actually committed anything in your cloned empty repo.
git add .
git commit -m "new commit"
git push
Second, the git send-email
doc does mention:
--subject=<string>
Specify the initial subject of the email thread. Only necessary if
--compose
is also set.
Make sure to use --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.
That would work with a .patch
, not the source itself.
See git format-patch
, and "How to send patches with 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
. That generates one file that you can send any way you want, and from which the receiver can pull/clone from. It acts (that one file) as a bare git repo.