Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何合并两个不同的存储库?_Git_Git Merge - Fatal编程技术网

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

我有两个存储库,一个在Bitbucket中,另一个在Github中

我想做的是:将Bitbucket的存储库合并到Github存储库中,同时保留Bitbucket存储库的提交历史记录。合并后,Github的repo应该在Bitbucket的存储库提交历史记录旁边有自己的提交历史记录。我希望避免在Github中创建新的存储库

如何使用git执行上述操作?

您可以试试这个

  • 克隆GitHub存储库

    git clone <github-repo-url>
    
    git remote add <some-remote-name> <bitbucket-repo-url>
    
  • 使用
    --force
    选项推送到GitHub remote

    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>