git patch使用
Git 提供了两种补丁方案,一种是通过 git diff 生成的 .diff 文件,第二种是通过 git format-patch 生成的 .patch 文件。
通过 git diff 生成的文件不含有 commit 信息,可以指定文件生成 diff,也可以指定单个 commit, 多个 commit 生成 。
通过 git format-patch 生成的 .patch 文件 含有 commmit 信息。一个 commit 对应一个 patch 文件,也可以整合到一个 patch 文件里。
此方案只针对某一个 branch 的代码的迁移。
1. git format-patch
此命令用于生成 patch 文件。
某次提交以后的所有 patch:
1 | |
2. git am
此命令用于打 patch 文件入分支。
1 | |
3. Usage
使用流程:start -> 云桌面查看待同步分支最新 commitId -> 内网切换到需要同步的分支 -> 内网 git format-patch -> 打包 patch 文件内传外(包含代码,需要有高权限的人才可以传) -> 云桌面解包 -> git am -> over。
git patch使用
https://www.920929.xyz/posts/8470973f.html