What is the difference between git am and git apply?

后端 未结 3 509
日久生厌
日久生厌 2020-12-04 07:49

Both git am and git apply can be used to apply patches. I fail to see the difference. I see a difference now: git am automatically com

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 08:31

    Both the input and output are different:

    • 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.

    git am uses git apply behind the scenes, but does more work before (reading a Maildir or mbox, and parsing email messages) and after (creating commits).

提交回复
热议问题