git send-email (multiple patches)

来源:互联网 发布:精品php源码 编辑:程序博客网 时间:2024/05/19 16:47

ref : http://stackoverflow.com/questions/14075445/how-to-generate-separate-patch-files-for-many-local-commits-and-send-them-with


1) Download source code from the git repository:

git clone git://address.of.repository/project/ /folder/path/on/my/computer

2) Create your git branch in the project. this branch will continue all your local commits

git checkout -b <private_branch_name>

3) set your email address and your name for the git commit signature:

git config --global user.name "Your Name"git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

4) Do your modifications on the source code. a new files/folders could be added in the project.

Each modification could be commited alone locally:

5) Before commit the changes. we have to add the new files/folders to the local git repository:

under the project folder of the source code

git add <Newfolder>git add <Newfile>

6) And then commit locally a modification with:

under the project folder of the source code

git commit -a

this will open an interactif window

you can check that commit has detected the edited files and the new files under:

# Changes to be committed:#   (use "git reset HEAD <file>..." to unstage)##       modified:   bin/Makefile.am#       modified:   configure.ac#       new file:   src/new.c

under the window of commit -a, you have to enter comment for your modifications

and then save your commit with Ctrl + O ( WriteOut) and thenEnter and your commit is become saved now

and then quit the commit -a window with Ctrl + X (Exit)

Note: You need to put a blank line between comments in order to get the email subject and the email core in your patch file that you will send via eamil

7) After making all the commits for each modification, now you can generate separate patch for each commit with:

under the project folder of the source code

 git format-patch --cover-letter -M master -o ../outgoing/

this will generate a patch file for each commit undo the folder outgoing

The generated files in the outgoing folder are letters containing email subject and email core and the patch enclosed in the letter.

You can check that there is letter with subject [PATCH 00/25]. This letter contains a summary for other letter patches with subjects[PATCH 01/25][PATCH 02/25] [PATCH 03/25] ...

Do not forget to edit the file [PATCH 00/25]. Set the email subject and the email core

If you want to generate the patches with signed-off-by just add -s:

git format-patch -s --cover-letter -M master -o ../outgoing/

8) and then to send the letters with the git command:

git send-email --to=email.address@destination.com --cc=email.address2@destination.com --cc=email.address3@destination.com outgoing/*

To use git send-email to send your patches , edit ~/.gitconfig to specify your account settings:

[sendemail]        smtpencryption = tls        smtpserver = smtp.gmail.com        smtpuser = yourname@gmail.com        smtpserverport = 587