[email protected]:thunderrabbit/thunderrabbit.github.com.git
新远程=
[email protected]:tr/tr.newrepo.git
在您本地机器上的终端:
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的
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数据,所有分支都复制为本地。然后将原点更改为指向新的遥控器,然后按所有分支和标签。 这不需要脚本,不需要列表分支,只需几个通用的单线。