git - 将 Git 存储库内容移动到另一个保留历史记录的存储库

标签 git merge repository migrate

我尝试使用以下命令仅将一个存储库 (repo1) 的内容移动到另一个现有存储库 (repo2):

git clone repo1
git clone 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-histories
git remote rm r1remote

在那之后 repo2/master 将包含 repo2/masterrepo1/master 的所有内容,并且还将包含两者的历史他们。

关于git - 将 Git 存储库内容移动到另一个保留历史记录的存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17371150/

相关文章:

gitlab 在项目页面上显示错误的自述文件

git - Cherry-pick merge 提交失败,提交为空

c++ - 如何通过键有效地合并 k 个排序的成对键/值 vector ?

java - Sonatype Nexus 中基于代理 SVN Google Code 的 maven 存储库

javascript - 有没有办法使用 Grunt.js 在 Windows 上的 git shell 中调用命令

git - 允许代理转发使用 Cmder (ConEmu)

java - 如何防止 Maven 2 搜索远程存储库以获取特定的本地依赖项?

c# - 在 Repository Pattern 中,我应该在哪里实现 Distinct 方法?

git - 使用 mysygit (GitGui) 时,是否有执行 git bash 命令的日志?

r - 如何合并数据框中的行并组合单元格中的因子值