Windows 中跨本地文件系统的 GIT 克隆存储库 [英] GIT clone repo across local file system in windows

查看:32
本文介绍了Windows 中跨本地文件系统的 GIT 克隆存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当谈到 GIT 时,我是一个完整的菜鸟.在过去的几天里,我刚刚迈出了第一步.我在我的笔记本电脑上设置了一个 repo,从一个 SVN 项目中拉下 Trunk(分支有一些问题,没有让它们工作),但那里似乎一切正常.

I am a complete Noob when it comes to GIT. I have been just taking my first steps over the last few days. I setup a repo on my laptop, pulled down the Trunk from an SVN project (had some issues with branches, not got them working), but all seems ok there.

我现在希望能够从笔记本电脑拉或推到我的主桌面.原因是笔记本电脑在火车上很方便,因为我每天花 2 小时旅行,可以完成一些很好的工作.但是我家里的主机很适合开发.所以我希望回家后能够从笔记本电脑推/拉到主电脑.我认为最简单的方法是让代码文件夹在 LAN 上共享,然后执行:

I now want to be able to pull or push from the laptop to my main desktop. The reason being the laptop is handy on the train as I spend 2 hours a day travelling and can get some good work done. But my main machine at home is great for development. So I want to be able to push / pull from the laptop to the main computer when I get home. I thought the most simple way of doing this would be to just have the code folder shared out across the LAN and do:

git clone file://192.168.10.51/code

不幸的是,这似乎对我不起作用:

unfortunately this doesn't seem to be working for me:

所以我打开一个 git bash cmd 并输入上面的命令,我在 C:code(两台机器的共享文件夹)这是我得到的:

so I open a git bash cmd and type the above command, I am in C:code (the shared folder for both machines) this is what I get back:

Initialized empty Git repository in C:/code/code/.git/
fatal: 'C:/Program Files (x86)/Git/code' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

如何以最简单的方式在两台机器之间共享存储库.

How can I share the repository between the two machines in the most simple of ways.

将有其他位置作为官方存储点以及其他开发人员和 CI 服务器等将从中提取的位置,这样我就可以在两台机器上处理同一个存储库.

There will be other locations that will be official storage points and places where the other devs and CI server etc will pull from, this is just so that I can work on the same repo across two machines.

根据塞巴斯蒂安的建议,我得到以下信息:

As per Sebastian's suggestion I get the following:

C:code>git clone --no-hardlinks file://192.168.10.51/code
Initialized empty Git repository in C:/code/code/.git/
fatal: 'C:/Program Files (x86)/Git/code' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

**编辑 - 答案 **

**EDIT - ANSWER **

感谢所有帮助.我尝试了映射驱动器,并且奏效了,所以我想我会在不映射的情况下返回并重试.最后的结果是:

Thanks to all that helped. I tried the mapping a drive and that worked so thought I would go back and retry without mapping. The final result was:

git clone file://\\192.168.0.51code

效果很好.

谢谢

推荐答案

您可以通过应用 UNC 文件协议的路径.这需要您使用四个斜杠:

You can specify the remote’s URL by applying the UNC path to the file protocol. This requires you to use four slashes:

git clone file:////<host>/<share>/<path>

例如,如果您的主机具有 IP 192.168.10.51 和计算机名称 main,并且它有一个名为 code 的共享它本身是一个 git 存储库,那么以下两个命令应该同样有效:

For example, if your main machine has the IP 192.168.10.51 and the computer name main, and it has a share named code which itself is a git repository, then both of the following commands should work equally:

git clone file:////main/code
git clone file:////192.168.10.51/code

如果 Git 存储库在子目录中,只需附加路径:

If the Git repository is in a subdirectory, simply append the path:

git clone file:////main/code/project-repository
git clone file:////192.168.10.51/code/project-repository

这篇关于Windows 中跨本地文件系统的 GIT 克隆存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆