git - 如何 git 修补 git 中的整个分支/标签以将其应用到另一个未更新的存储库上?

标签 git github

我有一个 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/

相关文章:

git - Github 如何实现其 Pull Request 功能

github - 有没有办法在 github enterprise 中将组织所有者更改为站点管理员?

git - 如何只公开私有(private) git 存储库的一个文件?

Git pull origin <branch> 覆盖 master?

git - Flutter:如何获取Firebase插件的GitHub主版本

git - 在 Android Studio 中压缩 Git 分支提交

git - 如何清理和准备我想公开的 git 存储库?

git - 如何知道 git 浅克隆的深度?

git - 如何在 Mac 中定位 git 配置文件

github - 在单台 PC 中为 github 和 bitbucket 添加 SSH key