将 git 存储库移至另一台服务器
我在开发服务器上有一个 git 克隆/存储库,但我现在正在转移到另一台服务器。我不想将所有本地分支和更改提交到主存储库,那么如何将旧服务器上的所有内容精确复制到新服务器?
我尝试了 oldserver:~$ scp -rp project newserver:~/project
但当尝试在 newserver 上执行任何操作时,我只是收到大量“typechange”错误。
有人提到了 x 模式,但是在服务器之间移动文件时如何保留它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想要 git 解决方案,您可以尝试,
尽管这仅适用于裸存储库。
如果这是一个非裸存储库,您也可以进行正常的克隆,然后进行如下操作:
中间步骤当然可以通过 5000 种不同的方式完成,但这就是其中一种! (请注意,bash 中的管道之后不需要续行 - 它知道需要更多输入)
最后,如果您想直接复制,我建议使用 rsync 而不是 scp (可能使用 -avz 选项?)。 (这些类型更改错误到底是什么?)
If you want a git solution, you could try
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:
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?)
我实际上已经做到了这一点,我所做的只是先将存储库 tar 起来并对其进行 scp 。我认为 scp -rp 也可以工作。
“类型更改”通常指的是诸如符号链接变成文件之类的事情,反之亦然。两台服务器运行相同的操作系统吗?
I've actually done this, and all I did was tar the repo up first and scp it over. I would think that scp -rp would work as well.
"Typechange" would normally refer to things like a symlink becoming a file or vice-versa. Are the two servers running the same OS?
您可能还想尝试简单的愚蠢解决方案 - 不要担心类型更改是如何到达那里的,而是让 git 使用重置命令修复它们:
只有当(1)问题都与签出有关时,这才有意义文件(而不是存储库结构本身)以及 (2) 您尚未对需要保留的 newserver 进行任何更改。
考虑到这些警告,当我发现自己遇到同样的问题时,它对我很有用,并且不需要您考虑 git 的内部结构或文件传输过程保留属性的情况。
You may also want to try the simple dumb solution -- don't worry about how the typechanges got there, but let git fix them with a reset command:
That only makes sense if (1) the problems all pertain to the checked-out files (and not the repository structure itself) and (2) you haven't made any changes on newserver which you need to preserve.
Given those caveats, it worked for me when I found myself with the same problem, and it doesn't require you to think about git's internals or how well your file-transfer process is preserving attributes.