我有一个本地Git回购,我想把它推到一个新的远程回购(全新的回购设置在Beanstalk上,如果这很重要的话)。 我的本地回购有一些分支和标签,我想保留我的所有历史。
看起来我基本上只需要做一个git推送,但这只上传主分支。
我如何推动所有东西,以便在遥控器上获得本地回购的完整副本?
我有一个本地Git回购,我想把它推到一个新的远程回购(全新的回购设置在Beanstalk上,如果这很重要的话)。 我的本地回购有一些分支和标签,我想保留我的所有历史。
看起来我基本上只需要做一个git推送,但这只上传主分支。
我如何推动所有东西,以便在遥控器上获得本地回购的完整副本?
当前回答
如果目的地是空的,这是我发现的最简洁的方法。切换到一个空文件夹,然后:
# Note the period for cwd >>>>>>>>>>>>>>>>>>>>>>>> v
git clone --bare https://your-source-repo/repo.git .
git push --mirror https://your-destination-repo/repo.git
用https://..。对于文件:///your/repo等。
其他回答
以下是我解决[远程拒绝]时,我将本地Git回购到新的远程,包括所有分支和标签
Git克隆——镜像old-repo cd < name-repo.git > Git远程添加新的new-repo Git push new——mirror
在像我这样的情况下,你获得了一个回购,现在将远程源切换到一个不同的回购,一个新的空的…
你在里面有repo和所有分支,但你仍然需要为git push -all命令签出这些分支。
你应该在推之前这样做:
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done
紧随其后的是
git push --all
我最喜欢的(也是最简单的)方法
git clone --mirror OLD_GIT_URL
cd NEW_CREATED_FOLDER
git remote add NEW-REMOTE NEW_GIT_URL
git push NEW-REMOTE --mirror
镜像存储库
创建存储库的裸克隆。
git clone --bare https://github.com/exampleuser/old-repository.git
镜像推送到新的存储库。
cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
删除在步骤1中创建的临时本地存储库。
cd ..
rm -rf old-repository.git
镜像包含Git大文件存储对象的存储库
创建存储库的裸克隆。将示例用户名替换为拥有存储库的个人或组织的名称,并将示例存储库名称替换为希望复制的存储库的名称。
git clone --bare https://github.com/exampleuser/old-repository.git
导航到刚才克隆的存储库。
cd old-repository.git
导入存储库的Git大文件存储对象。
git lfs fetch --all
镜像推送到新的存储库。
git push --mirror https://github.com/exampleuser/new-repository.git
将存储库的Git大文件存储对象推到镜像。
git lfs push --all https://github.com/exampleuser/new-repository.git
删除在步骤1中创建的临时本地存储库。
cd ..
rm -rf old-repository.git
以上说明来自Github帮助:https://help.github.com/articles/duplicating-a-repository/
如果目的地是空的,这是我发现的最简洁的方法。切换到一个空文件夹,然后:
# Note the period for cwd >>>>>>>>>>>>>>>>>>>>>>>> v
git clone --bare https://your-source-repo/repo.git .
git push --mirror https://your-destination-repo/repo.git
用https://..。对于文件:///your/repo等。