如何合并两个不同的存储库?
How do I merge two different repositories?
我有两个存储库,一个在 Bitbucket 中,另一个在 Github 中。
我想做的是:将 Bitbucket 的存储库合并到 Github 存储库中,同时保留 Bitbucket 存储库的提交历史记录。合并后,Github 的仓库应该有自己的提交历史以及 Bitbucket 的仓库提交历史。我想避免在 Github.
中创建新的存储库
如何使用 git 执行上述操作?
你可以试试这个
克隆 GitHub 存储库
git clone <github-repo-url>
在克隆的存储库中将 Bitbucket 存储库添加为远程
git remote add <some-remote-name> <bitbucket-repo-url>
合并新的远程分支,选项为--allow-unrelated-histories
git fetch <some-remote-name>
git merge --allow-unrelated-histories <remote-name>/<branch-name>
使用 --force
选项推送到 GitHub 远程
git push --force <github-remote-name>
请注意,合并操作可能会导致合并冲突。您可以查看此 How do you merge two Git repositories? 以获得更多选项。
它将允许您在推送到 bitbucket 时自动将更改拉取到 github。
我有两个存储库,一个在 Bitbucket 中,另一个在 Github 中。
我想做的是:将 Bitbucket 的存储库合并到 Github 存储库中,同时保留 Bitbucket 存储库的提交历史记录。合并后,Github 的仓库应该有自己的提交历史以及 Bitbucket 的仓库提交历史。我想避免在 Github.
中创建新的存储库如何使用 git 执行上述操作?
你可以试试这个
克隆 GitHub 存储库
git clone <github-repo-url>
在克隆的存储库中将 Bitbucket 存储库添加为远程
git remote add <some-remote-name> <bitbucket-repo-url>
合并新的远程分支,选项为
--allow-unrelated-histories
git fetch <some-remote-name> git merge --allow-unrelated-histories <remote-name>/<branch-name>
使用
--force
选项推送到 GitHub 远程git push --force <github-remote-name>
请注意,合并操作可能会导致合并冲突。您可以查看此 How do you merge two Git repositories? 以获得更多选项。
它将允许您在推送到 bitbucket 时自动将更改拉取到 github。