Install packages:
On Ubuntu, I have done: sudo apt-get install git git-email
Stage1: development:
set up your GIT variables(probably in ~/.bashrc)
export GIT_COMMITTER_EMAIL=yourEmail@somewhere.com
export GIT_COMMITTER_NAME='YourName'
export GIT_AUTHOR_EMAIL=yourEmail@somewhere.com
export GIT_AUTHOR_NAME='YourName'
git clone ... or git pull.. etc to get to the latest code.
git branch branch_name
git checkout branch_name
Do changes
git commit with commit message in incremental stages..
Stage 2: Generate email-able patch files.
git-format-patch -s -n -o
-s will generate the signed of-by
-n will generate numbered patches (if you have just a single patch, you can ignore it) - but if you have multiple ones, this is a good idea to use to generate subject auto numbered 1/2, 2/2 etc..
-o is where the output patch files will be stored -> each commit is a separate file.
Stage3: Email the patches:(for gmail)
Simple one (no mail threads):
git-send-email --from "My Name
See --thread in man git-send-email for further info.. this is a pretty versatile tool.. just need to get used to it I guess
8 comments:
Very instructive, thanks!
glad to be of help..
At newer git versions (>= 1.6) it seems that the command is now "git send-email", i.e. without a hyphen between git and send.
If you have some details how to do threaded mails for more than one patch, don't hesitate to write about it. Dirk :)
Dirk, thanks.. i think we should be able to script that in.. will check it.. and update post if I find something..
Regarding threaded mails (e.g. if you want to send more than one patch):
Instead of (one) "PatchFile" you can pass a directory with several patches to git send-email. In this directory you have your x patches you want to send (and only the patches!). At best, you order the patches by numbering them (e.g. 0001-patch1, 0002-patch2 etc.). If you pass this directory to git send-email then, all the files in this directory will be sent.
The question now is where to get the mail subjects from. As we want individual subjects for each patch, but all patches are sent automatically, we can't specify the subject with --subject any more. For this, you can have the subject stored in the header of your patch (file). E.g. with
-- cut --
Subject: [PATCH 1/3]: Testmail1
Test 1
Signed-off-by: A B a@b.com
-- cut --
git send-email will pick the subject from the patch file. The resulting mail will contain "[PATCH 1/3]: Testmail1" as subject and the body will start with "Test 1" (!).
Next question is threaded mails. Some mailing lists like to have several patches to be sent threaded, i.e. all patches have to be sent as 'reply to' to the first one. With git send-email there are two tastes of threading possible:
--chain-reply-to:
Each (patch) mail will be a reply to the previous one. I.e.:
x
|-x
__|-x
____|-x
______|-...
--no-chain-reply-to:
Each (patch) mail will be a reply to the first mail. I.e.:
x
|-x
|-x
|-x
|-...
Dirk
Btw.: Should we create a (eLinux) wiki page for this?
Wow... that was amazing information.. yeah, I think we should generate a wiki for this.... most folks dont know abt this
One pitfall:
Make really sure that the
Subject: ...
is at the _first_ line of all your patches if you use directory mode for a patch series. If there is one empty line before it, git send-email might be confused and take the subject from e.g. previous patch...
Wiki page created:
http://elinux.org/Git_usage#send-email
Dirk
Post a Comment