一:补丁作用
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后就可以了
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。