将一个git仓库移到另一台服务器上

编程入门 行业动态 更新时间:2024-10-22 15:24:37
本文介绍了将一个git仓库移到另一台服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在开发服务器上有一个git clone / repo,但现在我正在转向另一个。我不想提交所有本地分支机构和主存储库的更改,那么如何才能将旧服务器上的所有内容复制到新服务器?

我试过 oldserver:〜$ scp -rp project newserver:〜/ project

但是我只需要加载和加载尝试在newserver上执行任何操作时出现typechange错误。

有人对x模式进行了说明,但是如何在服务器之间移动文件时保留该模式?

解决方案

如果您想要一个git解决方案,您可以尝试

git clone --mirror< oldurl> < NEWURL>

虽然这只适用于裸仓库。

如果这是一个非裸回购,你也可以做正常的克隆,接下来是这样的:

git获取原点 git branch -r | grep'^ * origin / [^] * $'| 读取rb;做的git分支 - 无轨道$ {rb#* /} $ rb;完成 git remote rm origin

中间步骤当然可以用5000种不同的方式完成,但那是一个! (请注意,在bash中的管道之后不需要延续线\ - 它知道它需要更多输入)

最后,我建议使用rsync代替如果你想直接复制scp(可能带有-avz选项?)。 (这些typechange错误到底是什么?)

I have a git clone/repo on a development server, but I am now moving to another one. I don't want to commit all my local branches and changes to the main repository, so how can I make an exact copy of everything on oldserver to newserver?

I tried oldserver:~$ scp -rp project newserver:~/project

but then I just get loads and loads of "typechange" errors when trying to do anything on newserver.

Someone said something about x-modes, but how can I preserve that when moving files between servers?

解决方案

If you want a git solution, you could try

git clone --mirror <oldurl> <newurl>

though this is only for bare repositories.

If this is a non-bare repo, you could also do the normal clone, followed by something like this:

git fetch origin git branch -r | grep '^ *origin/[^ ]*$' | while read rb; do git branch --no-track ${rb#*/} $rb; done git remote rm origin

The middle step can of course be done in 5000 different ways, but that's one! (note that the continuation line \ isn't necessary after the pipe in bash - it knows it needs more input)

Finally, I'd suggest using rsync instead of scp (probably with -avz options?) if you want to directly copy. (What exactly are these typechange errors?)

更多推荐

将一个git仓库移到另一台服务器上

本文发布于:2023-11-28 13:05:20,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:移到   仓库   另一台   器上   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!