git am和git apply有什么区别? [英] What is the difference between git am and git apply?

查看:753
本文介绍了git am和git apply有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用 git am git apply 来应用修补程序。我看不出有什么不同。我现在看到一个区别: git am 会自动提交,而 git apply 只会触及这些文件,但不会创建提交。这是唯一的区别吗?

解决方案

输入和输出都是不同的:


  • git apply 需要一个补丁(例如 git diff )并将其应用于工作目录(或索引,如果 - index - 使用cached )。
  • git am 需要一个提交邮箱格式化为电子邮件信息(例如 git format-patch )并将它们应用于当前分支。
    / b>

    git am 使用 git apply 幕后,但之前做了更多工作(阅读 Maildir mbox ,并解析电子邮件)和之后(创建提交)。


    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 commits whereas git apply only touches the files but doesn't create a commit. Is that the only difference?

    解决方案

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

    这篇关于git am和git apply有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆