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
With git am
you apply the patch so if you use git status
you won't see any local changes.
git apply
enables you to make the changes in the source files as if you were writing the code by yourself, consequently git status
and git diff
will output the changes made in the patch you have applied, then you can fix/add more changes and submit them together as one new patch.
git apply
is for applying straight diffs (e.g. from git diff
) whereas git am
is for applying patches and sequences of patches from emails, either mbox or Maildir format and is the "opposite" of git format-patch
. git am
tries to extract commit messages and author details from email messages which is why it can make commits.
Both the input and output are different:
--index
or --cached
is used).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).