git补丁相关操作

huaweichenai -
git补丁相关操作
一:补丁作用

git补丁作用是即将改动的代码统一添加到一个补丁文件中,扩展名一般为.patch,将补丁发送到需要的版本中,然后再执行创建补丁命令,这样改动会自动合并到该版本库中

二:创建补丁
git format-patch -s [commit id] #将指定提交[commit id]之后的所有提交创建补丁,不包括[commit id]提交本身
git format-patch -s [commit id1]..[commit id2] #将指定提交[commit id1]到[commit id2]之间的所有提交创建补丁
git format-patch -M [master] #将指定分支[master]到当前分支的所有提交创建补丁
三:应用补丁
git am [xxx.patch] #应用指定补丁
git am --signoff --ignore-whitespace -p1 --directory=project < xxx.patch #应用指定补丁到指定目录下
git am *.patch #应用所有补丁
git am --signoff --ignore-whitespace -p1 --directory=project < *.patch #应用所有补丁到指定目录下
四:git am报错解决

在执行git am命令时提示:

fatal: previous rebase directory .git/rebase-apply still exists but mbox given.

解决方案:

git am --abort

执行上面命令后再执行git am后就可以了

特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Tags 标签

git

扩展阅读

加个好友,技术交流

1628738909466805.jpg