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 [email protected]. 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 [email protected] --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:
- Created a Empty Repository on Github : "MyRepo"
- Cloned it on local machine. (using git clone )
- Then added the first file "hello_world.c" into the Directory /MyRepo".
- 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 [email protected] --subject="[asdasdas] assd asdasd" hello_world.c
Now I get an Error:
No subject line in hello_world.c ? at /usr/lib/git-core/git-send-email line 584
First make sure you have actually committed anything in your cloned empty repo.
Second, the
git send-email
doc does mention:Make sure to use
--compose
.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:
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.