我正在尝试使用以下命令将一个存储库(repo1)的内容移动到另一个现有的存储库(repo2):
git clone repo1
git clone repo2
cd repo1
git remote rm origin
git remote add repo1
git push
但这并不奏效。我看过一篇类似的文章,但我只发现一个人移动了文件夹,而不是内容。
我正在尝试使用以下命令将一个存储库(repo1)的内容移动到另一个现有的存储库(repo2):
git clone repo1
git clone repo2
cd repo1
git remote rm origin
git remote add repo1
git push
但这并不奏效。我看过一篇类似的文章,但我只发现一个人移动了文件夹,而不是内容。
当前回答
我不太确定我所做的是否正确,但无论如何它都起作用了。我重命名了repo1中的repo2文件夹,并提交了更改。在我的情况下,这只是一个回购,我想合并,所以这种方法是有效的。后来,进行了一些路径更改。
其他回答
镜像存储库
根据@Dan-Cohn的回答,镜像推送是你的朋友。这是我的迁移回购:
1.打开Git Bash。
2.创建存储库的裸克隆。
$ git clone --bare https://github.com/exampleuser/old-repository.git
3.镜像推送到新的存储库。
$ cd old-repository.git
$ git push --mirror https://github.com/exampleuser/new-repository.git
4.删除在步骤1中创建的临时本地存储库。
$ cd ..
$ rm -rf old-repository.git
参考文献和出处:https://help.github.com/en/articles/duplicating-a-repository
这工作移动我的本地回购(包括历史)到我的远程github.com回购。在GitHub.com上创建新的空回购后,我使用下面第三步中的URL,它工作得很好。
git clone --mirror <url_of_old_repo>
cd <name_of_old_repo>
git remote add new-origin <url_of_new_repo>
git push new-origin --mirror
我在https://gist.github.com/niksumeiko/8972566上找到了这个
我使用下面的方法通过维护所有分支和提交历史来将我的GIT Stash迁移到GitLab。
将旧的存储库克隆到本地。
git clone --bare <STASH-URL>
在GitLab中创建一个空存储库。
git push --mirror <GitLab-URL>
我做了什么:
克隆存储库到一个文件夹 cd现有项目 这里打开一个git终端 git remote set-url origin <NEW_GIT_REPO> Git push -u origin——all Git push origin—tags
对于那些使用GitHub的人,你可以通过web UI导入另一个存储库(包括历史):
https://github.com/new/import