我有一个 git 存储库,其分支名为development,标签为 v1.14, 我在不同位置有相同的存储库,但没有互联网连接/连接速度慢。
我需要为开发分支创建一个补丁并邮寄该补丁以便可以应用它。
我的锻炼:
git format-patch --root v1.14 --stdout > ../git-for-mail/patches
在远程存储库中我执行以下命令:
git am --ignore-whitespace < ~/workspace/git-for-mail/patches
我收到这些错误:
error: .gitignore: already exists in index
error: Gemfile: already exists in index
error: db/migrate/20140819091734_add_customer_number_to_location.rb: already exists in working directory
Patch failed at 0001 Implemented PC-81 & PC-77.
Applying: Adding Comments for PC-77
error: patch failed: lib/kitting/app/controllers/kitting/kit_copies_controller.rb:13
error: lib/kitting/app/controllers/kitting/kit_copies_controller.rb: patch does not apply
error: patch failed: lib/kitting/app/controllers/kitting/locations_controller.rb:6
error: lib/kitting/app/controllers/kitting/locations_controller.rb: patch does not apply
Patch failed at 0002 Adding Comments for PC-77
请告诉我是否有任何替代解决方案或解决此问题的技巧。
提前致谢!!!
桑托什·莫汉蒂
最佳答案
使用--root
标志,您的format-patch
命令正在生成补丁all the way back to the first commit in the repository :
Examples
Extract all commits that lead to origin since the inception of the project:
$ git format-patch --root origin
这会导致 Git 尝试创建远程上已存在的提交。相反,找出远程存储库上的最新提交是什么,并从该点开始创建补丁。
在远程存储库中:
git rev-parse --short HEAD # Outputs something like 1234abc
在您的本地存储库中,根据您刚刚获得的标签哈希生成补丁:
git format-patch 1234abc..v1.14 --stdout > ../git-for-mail/patches
最后,使用原始命令将补丁应用到远程存储库。
关于git - 如何 git 修补 git 中的整个分支/标签以将其应用到另一个未更新的存储库上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25742147/