How to use git am to apply patches from email messages?

前端 未结 3 1409
无人共我
无人共我 2020-12-28 15:10

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 o

3条回答
  •  清酒与你
    2020-12-28 15:57

    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 --to=maintainer@project.com --from=me@here.com ... *.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.

提交回复
热议问题