Open Source Git Workflow

Contributing to Open Source projects in your free time can be more difficult when you need to pass your patches by a reviewer at work before sending them to the project. It pays off to invest a little time into making this workflow more streamlined. Since most projects use Git these days, I use that:

Optional: Change your email address

If you want to submit patches using your work mail address, start by configuring it in the project you're patching:

git config user.email 'me@work.example.com'
git config user.name 'My name'

All further local commits will use this email address.

Make changes and commit them locally

This is the hardest step. It involves programming. ;)

Create patches you want to submit

Assuming your project accepts patches on a mailing list.

git format-patch -3

The -3 will create one patch file for each of the last 3 commits.

Patch files are in mbox format and can be hand-edited before sending them out. Make sure they look like the mails you want to send out in the end.

Fire the .patch files off to work.

A simple way is to send them off via mail.

On Arch Linux using the s-nail client, you can do it on the command line like so:

$ mail -A mailconfig -s "My newest patches" \
       -a 0001-Fixes.patch                  \
       -a 0002-More-fixes.patch             \
       -a 0003-Even-more-fixes.patch        \
       me@work.example.com

My ~/.mailrc is configured to use my private address:

account mailconfig {
  # Never ever use unencrypted SMTP!
  # Configure authentication and encryption
  # according to mail(1)'s entry on smtp-auth.
  set smtp=smtp://smtp-host:25
  set from=me@private.example.com
}

When at work

Forward the mail with the .patch files to the person responsible for approving the patch, and wait for response.

Sending the patch

Assuming a patch has been approved, send it out in git like this:

git send-email --to='devel-ml@project.example.com' \
               0001-Fixes.patch

This assumes that git is configured again to use the right SMTP server; This can be done again using git config:

# Never ever use unencrypted SMTP!
# See authentication and encryption options in git-send-email(1).
# The man page has an example for the GMail SMTP server at the bottom.
git config --global sendemail.smtpserver smtp-host.example.com
git config --global sendemail.smtpserverport = 25