Git 如何合并两个不同的存储库?
我有两个存储库,一个在Bitbucket中,另一个在Github中 我想做的是:将Bitbucket的存储库合并到Github存储库中,同时保留Bitbucket存储库的提交历史记录。合并后,Github的repo应该在Bitbucket的存储库提交历史记录旁边有自己的提交历史记录。我希望避免在Github中创建新的存储库 如何使用git执行上述操作?您可以试试这个Git 如何合并两个不同的存储库?,git,git-merge,Git,Git Merge,我有两个存储库,一个在Bitbucket中,另一个在Github中 我想做的是:将Bitbucket的存储库合并到Github存储库中,同时保留Bitbucket存储库的提交历史记录。合并后,Github的repo应该在Bitbucket的存储库提交历史记录旁边有自己的提交历史记录。我希望避免在Github中创建新的存储库 如何使用git执行上述操作?您可以试试这个 克隆GitHub存储库 git clone <github-repo-url> git remote add &l
- 克隆GitHub存储库
git clone <github-repo-url>
git remote add <some-remote-name> <bitbucket-repo-url>
- 使用
选项推送到GitHub remote--force
git push --force <github-remote-name>
git推送--force
请注意,合并操作可能会导致合并冲突。您可以在这里查看更多选项。您可以在这里查看git mirror
它允许您在推到bitbucket时自动将更改拉到github。有帮助吗?将另一个
git remote
,git fetch
添加到repo中,并对分支使用git merge
。我明白了,如果我想在相反方向合并它们(即将Github repo同化为Bitbucket repo),这也很有效,对吗?@Richard,是的,对force
选项要小心一点,谢谢,我将尝试以上当我有权访问回购和更新你。
git push --force <github-remote-name>