最近我从 SVN 迁移到 git,我的团队已经开始在新的 git 存储库中工作。
后来我发现了一些转换问题,并从 SVN 制作了第二个 git repo,并进行了一些修复和历史重写。
现在我有了 SVN 存储库的第二个 git 副本(我对此感到满意),我想用我的团队在第一个 git 存储库中所做的更改来修补它。
为此,我尝试使用 git 补丁:
git-format-patch --zero-commit --stdout > master.patch
创建 已经对第一个 git 的master
进行更改的单个文件 repo- 和
git-am
将来自*.patch
文件的提交应用到master
第二个存储库的
我指定了--zero-commit
,因为补丁文件中的哈希值是错误的,所以我实际上有两个不同的存储库。
问题是,当我尝试使用 git am master.patch
应用补丁时,我得到:
Applying: %commit_name% error: patch failed: readme.md:5 error: readme.md: patch does not apply Patch failed at 0001 %commit_name% The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
即使我在这个补丁中只有一个提交,我想将它应用到同一个 repo 上以获得相同的提交,但在另一个分支上。
最佳答案
看起来像添加 --ignore-whitespace
到 git am
解决了主要问题,但我仍然有这样的警告:
.git/rebase-apply/patch:56: trailing
warning: squelched 9 whitespace
errors warning: 14 lines add whitespace errors.
关于git - 如何在具有更改历史记录的存储库上应用 git 补丁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40864182/