如何在提交 ID 不匹配的两个相同存储库之间创建和应用 git 补丁
How to create and apply git patches between two identical repos with mismatching commit IDs
我从 GitHub 浅克隆了一个 git 存储库并将其移动到一个独立的私有 git 实验室服务器。为了将浅克隆推送到新的 repo,我不得不丢失提交 ID 和标签(我使用了这个答案:)。
现在我想在外部创建 git 补丁并将它们移动到私有 gitlab 服务器以保持私有项目更新。但我知道 git 补丁依赖于持久的提交 SHA 来工作——而且两个项目中的提交 SHA 不匹配。
有没有办法让我创建可用的补丁程序?
But I understand that git patches rely on persistent commit SHAs to work
是的,如果您正在使用 git am
to apply the patches generated by git format-patch
(as seen here)
git format-patch <first-commit-hash>^..<end-commit-hash>
但是如果您使用 git apply
,您应该能够将这些路径应用到您当前的工作目录,而无需检查正确的 SHA1。
参见“What is the difference between git am
and git apply
?”。
我从 GitHub 浅克隆了一个 git 存储库并将其移动到一个独立的私有 git 实验室服务器。为了将浅克隆推送到新的 repo,我不得不丢失提交 ID 和标签(我使用了这个答案:
现在我想在外部创建 git 补丁并将它们移动到私有 gitlab 服务器以保持私有项目更新。但我知道 git 补丁依赖于持久的提交 SHA 来工作——而且两个项目中的提交 SHA 不匹配。
有没有办法让我创建可用的补丁程序?
But I understand that git patches rely on persistent commit SHAs to work
是的,如果您正在使用 git am
to apply the patches generated by git format-patch
(as seen here)
git format-patch <first-commit-hash>^..<end-commit-hash>
但是如果您使用 git apply
,您应该能够将这些路径应用到您当前的工作目录,而无需检查正确的 SHA1。
参见“What is the difference between git am
and git apply
?”。