git 打patch和应用patch 流程

在公司里面做测试的时候,使用git打patch的时候,通常是使用 git am patch 或者 cat xx.patch | git apply patch.

git am方法打入patch主要适用于生成patch通过git format-patch生成的Git专用Patch。而git apply 通用与所有的通用patch (git diff就是打的标准patch)

如果是通过make diff打的patch,那么就不能用git am来打入patch。只能使用git apply 来打patch。

所以流程是,找到你打的branch : git branch -r (显示所有branch) , git checkout branch(切换到你的branch),git pull拉到最新的版本 或者使用 git reset --hard commitID

使用git am patch或者git apply patch 打入patch。然后在编译就行了!

 

 

先检查patch文件:git apply --stat newpatch.patch
查看补丁是否能够干净顺利地应用到当前分支中: git apply --check newpatch.patch
对于git diff生成的patch,你可以用git apply --check

 

git am file.patch

导入到库中,如果执行时失败,则最好执行:

git am --abort

将patch做适当修改后,再次尝试

 

目前掌握的这么多,之后再补充~

posted @ 2019-05-24 23:06  魔法少女希维尔  阅读(6741)  评论(0编辑  收藏  举报