Progress:
TIER 2 · MODULE 52· Intermediate

git mailsplit

Pre-step for git am on a big mailbox.

🎯 What & why

Splits a single mbox file (or a stream of concatenated emails) into one file per message, numbered 0001, 0002, etc. The git am workflow's first stage when feeding a big mailbox.

🧠 Mental model

Input: an mbox. Output: a directory of single-message files with zero-padded sequence numbers. That's it - no parsing, no patch extraction; that's mailinfo's job.

🛠️ Synopsis

git mailsplit -o<dir> [-b] [-d<prec>] [-f<nr>] [--keep-cr] [--mboxrd]
              [<mbox>|<dir>...]

# Typical use: explode a downloaded mbox
git mailsplit -o./patches inbox.mbox

# Result:
./patches/0001
./patches/0002
./patches/0003
...

🎚️ Switches & options

FlagWhat it does
-o<dir>Output directory (must exist); files are written here
-bTreat any file that isn't an mbox as a single bare email
-d<n>Use n-digit zero-padded numbers (default 4: 0001)
-f<n>Start numbering at n instead of 1
--keep-crPreserve CRLF line endings instead of normalizing to LF
--mboxrdParse as mboxrd format (handles >From un-escaping correctly)

💡 Use cases

🧪 Examples

Split an mbox
mkdir patches && git mailsplit -o./patches inbox.mbox
Custom width and start
git mailsplit -o./p -d3 -f10 inbox.mbox   # 010, 011, ...
Single bare email
git mailsplit -b -o./p single.eml
Then apply with am
git am ./patches/*

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.