Maildir format for storing mail has been introduced that exacly does what you describe: one message is stored in one separate file.
And there are Maildir drivers (backends) for some mail clients, and some mail delivery agents, and some mail access servres (IMAP or POP or web interface).
Of course, if your mail is stored in Maildirs, it is most easy to put it under usual version control.
So, you can look for Maildir backends for mail clients.
But, actually, syncronizing your mail storage can be quite a bit more tricky than syncronizing directories of files -- because of various flags (new, read), labels, movements or copies of messages between folders, and--the most tricky part--the server-internal message IDs used by mail access servers (IMAP) or mail clients. What are these IDs about? Well, it's important to preserve IDs between several copies of your mail storage in order for, say, the caching procedure of your mail client to run correctly.
I have explored this issue and written down some notes here: research on HOW TO backup an IMAP account. (But then I didn't have to complete that task, so the notes and my practical solution wasn't complete.)
The general idea I have arrived at is that using a mail client and simply putting Maildirs under version control does not give you everything you might want from managing the revisons of your mail storage. It is better to combine it with real IMAP servers (either remote or local) for uniform access to the mail, and with special tools that run on top of IMAP for syncronizing different copies/repositories/branches of your mail storage (the special tools will take care of the flags, labels, IDs correctly). Usual version control is OK for inspecting the revisions and for reverting to a past revision, but for merging branches (= syncronizing) I'd consider a more complex procedure:
You want to merge branches
- So you prepare the new state (revision)
C that will hold the merged state by copying one of them, e.g., copy
A to the new
- Then you use a tool (like "imapsync"; choose the one that matches your needs; I have listed a few such tools in my notes) to bring the new changes from B to C: imapsync
(this might assume that you are accessing the mail storage via IMAP through a server)
- Now commit
C (as the result of merging
B; before this, you might use an appropriate command in your VCS to write down the information that is the result of merging
A, e.g., something like "
git merge B -s ours --no-commit" in
Please explore the details yourself, I have only the general idea in mind, and I'm not running such a procedure in practice now.
I think this is a very interesting task to be done by usual well-known utilities, I'd like to hear more about successful setups to do this other people have come up with!
AFAIR I chose
offlineimap for my task of backing up an IMAP account in Git. BTW here's an answer with an example configuration of