我如何将远程git存储库移至另一个远程git repo?

问题描述 投票:0回答:3
远程=

[email protected]:thunderrabbit/thunderrabbit.github.com.git

新远程=
[email protected]:tr/tr.newrepo.git

	

在您本地机器上的终端:
git git-remote
3个回答
13
投票
cd ~ git clone <old-remote> unique_local_name cd unique_local_name for remote in `git branch -r | grep -v master `; \ do git checkout --track $remote ; done git remote add neworigin <new-remote> git push --all neworigin

那么,这些其他答案都没有很好地解释,如果您想
使用git的

9
投票
机制,然后您需要每个遥控器的本地分支版本 分支 您可以使用

git branch

创建本地分支。这将创建一个分支
参考您的
.git/refs/heads/目录,所有当地的目录 存储分支参考。 然后您可以在

git push

--all
选项标志上使用
--tags

git push <new-remote> --all # Push all branches under .git/refs/heads git push <new-remote> --tags # Push all tags under .git/refs/tags

注意
--all
--tags
不能一起使用,所以这就是为什么您必须 推两次

文献
相关的

git push
文档:

--all

命名每个裁判的命名,指定所有参考 refs/heads/

被推动

--tags 除了明确的Refspecs,还推了下方的所有参考 在命令行上列出。

refs/tags

还可以使用
--mirror

可用于推动分支和标签参考 曾经,但是这个标志的问题是它推动了所有参考
--mirror
,不仅是

.git/refs/

.git/refs/heads

,这可能不是 您想把什么推到遥控器。
,例如,可以从旧的 远方以及其他的遥控器 参考文献,例如

.git/refs/tags
,这是

--mirror

的副产品。
    
the想法是为每个旧的远程分支做: Checkout
pull
到新遥控器(不要忘记标签!)
例如:

.git/refs/remotes/<remote>/


您可以简单地更改您的
.git/refs/original/
存储库的URL:
git filter-branch
    
我发现最简单的方法是使用当地的裸露克隆。这意味着没有工作目录,只有GIT数据,所有分支都复制为本地。然后将原点更改为指向新的遥控器,然后按所有分支和标签。

这不需要脚本,不需要列表分支,只需几个通用的单线。

4
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.