将Git存储库内容移至另一个保存历史记录的存储库 [英] Moving Git repository content to another repository preserving history
本文介绍了将Git存储库内容移至另一个保存历史记录的存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图仅使用以下命令将一个存储库(比如repo1)的内容移动到另一个现有存储库(比如repo2);
- git克隆repo1
- git克隆repo2
- cd repo1
- git remote rm origin
- git remote add repo1
- git push
但它不起作用。我审查了其他类似的帖子,但我只发现移动文件夹不是内容。
我认为你正在寻找的命令是:
cd repo2
git checkout master
git remote add r1remote ** url-of-repo1 **
git fetch r1remote
git merge r1remote / master --allow-unrelated-history
git remote rm r1remote
之后, repo2 / master
将包含从 repo2 / master
和 repo1 / master
,并且也会有它们的历史记录。
I am trying to move only the contents of one repository (say repo1) to another existing repository (say repo2) using the following commands;
- git clone repo1
- git clone repo2
- cd repo1
- git remote rm origin
- git remote add repo1
- git push
But its not working. I reviewed the other similar post but i only found 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
After that repo2/master
will contain everything from repo2/master
and repo1/master
, and will also have the history of both of them.
这篇关于将Git存储库内容移至另一个保存历史记录的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文