cybrkyd

Bob and Alice: a git patch love story

 Sun, 25 Jan 2026 08:27 UTC

Sometimes, I need a silly story to help me remember the obscure; things I do not use or do very often. Like git patching via e-mail. Here’s a little love story.

---

Bob loves Alice. And Bob loves Alice’s git repository.

  1. Bob clones it.
  2. Bob makes his changes and commits them normally.

    git add .
    git commit
    
  3. Bob generates patch file(s) from his commit(s). This produces one .patch file per commit.

    git format-patch origin/main
    
  4. Bob sends the .patch file(s) via email as attachments. The attachment must be sent as-is (no inline pasting).

That is all that is required on Bob’s side.

Bob’s patch file is like a love letter…carefully crafted, full of intention, and best delivered intact. Signed, sealed, delivered, I’m yours!

---

Alice receives Bob’s patch via e-mail.

After careful consideration, she likes what she sees, and wants to take things forward.

Alice:

  1. Saves Bob’s .patch attachment(s) to disk.

  2. Ensures she’s on the target branch.

    git checkout main
    
  3. Applies the patch(es) with Git, preserving metadata.

    # For a single patch:
    git am bob-change.patch
    
    # For multiple patches:
    git am *.patch
    

Sometimes, love isn’t smooth sailing. If Alice’s repository has changed since Bob’s commit, Git might throw a conflict…like a misunderstanding in a relationship; a lover’s tiff, if you will.

Alice is kind, patient and understanding, so she checks the changes, resolves the conflicts, and commits to moving forward together.

Hopefully Alice works things out with Bob.

After a successful git am, the commit(s) are in Alice’s branch with Bob recorded as the author.

A match made in heaven!

With the patch(es) applied, Bob’s changes live happily ever after in Alice’s repository. Together forever.

Fin.

»
Tagged in:

Visitors: Loading...