本文介绍了将 Git 存储库内容移动到另一个存储库以保留历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下命令仅将一个存储库 (repo1
) 的内容移动到另一个现有存储库 (repo2
):
I am trying to move only the contents of one repository (repo1
) to another existing repository (repo2
) using the following commands:
git clone repo1
git clone repo2
cd repo1
git remote rm origin
git remote add repo1
git push
但它不起作用.我查看了一个类似的帖子,但我只发现一个移动文件夹,而不是内容.
But it's not working. I reviewed a similar post, but I only found one moving the folder, not the contents.
推荐答案
我认为您正在寻找的命令是:
I think the commands you are looking for are:
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
git merge r1remote/master --allow-unrelated-histories
git remote rm r1remote
之后 repo2/master
将包含来自 repo2/master
和 repo1/master
的所有内容,并且还将拥有两者的历史记录
After that repo2/master
will contain everything from repo2/master
and repo1/master
, and will also have the history of both of them.
这篇关于将 Git 存储库内容移动到另一个存储库以保留历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!