I am pretty familiar with git(the basic stuff atleast-branches, merges,collaboration with peers etc.) but the other day a friend of mine told me that we could use git with our mailbox. The command involved is git am
(manual page here).
Please could someone help me get started with git am
.
In order to apply a Git patch file, use the “git am” command and specify the Git patch file to be used. Referring to our previous example, make sure to check out to the branch where you want your patch file to be applied.
git am is a super useful command which can be used for many things as it's reading and parsing the mailbox containing the commits you specify and allows you to use only parts of the extracted data such as the code diff, the autor, the message…
git apply takes a patch (e.g. the output of git diff ) and applies it to the working directory (or index, if --index or --cached is used). git am takes a mailbox of commits formatted as an email messages (e.g. the output of git format-patch ) and applies them to the current branch.
The other big thing involved is git format-patch
. This will create the patches to be emailed; they can then be sent using git send-email
or directly. For example:
# create a patch for each commit from origin's master to yours git format-patch origin/master..master # now send them... # there are a zillion options here, and also some configuration; read the man page git send-email [email protected] [email protected] ... *.patch
git am
will accept the patches created by format-patch
, and apply them sequentially, for example:
git am *.patch
You'll have to figure out how to export the patches in mbox format from your mail client yourself, though I suppose you could also simply send them as attachments or transfer them directly.
You can try this out for yourself entirely within one repository to see how it works. Create a set of patches as above, then check out the starting point, and use git am
to apply the patches.
You need a mail client that can export mail as mbox file. Export the mails and run git-am your-mbox-file
. It's done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With