我的笔记本电脑硬盘上有一个本地存储库,运行 Windows 7,并且我想在共享网络驱动器上设置远程存储库。在共享网络驱动器上,我创建了一个文件夹 thisProject.git
并使用 git init --bare
在那里创建了一个裸存储库。我尝试按如下方式设置 Remote :
git remote add origin file://\\some.site.com\projects\fldr\Software Development\Git\thisProject.git
但这只给了我回应:
usage: git remote add [<options>] <name> <url>
等等,这似乎表明我的git remote add
命令格式不正确或者路径有问题。
我也尝试使用路径的映射网络驱动器版本:
git remote add origin file://u:\Software Development\Git\thisProject.git
这得到了相同的回应。
如果 Remote 位于这样的网络驱动器上,我应该如何添加它?
最佳答案
仔细检查您尝试执行的内容:
git remote add origin file://\\some.site.com\projects\fldr\Software Development\Git\thisProject.git
...实际用途是什么:
usage: git remote add [<options>] <name> <url>
计算命令中参数的数量和用法。
除了 git remote add
(并且<options>
您没有使用)您应该传递2参数:<name>
和<url>
,但您实际上传递了 3 个参数:
-
origin
-
file://\\some.site.com\projects\fldr\Software
-
Development\Git\thisProject.git
您必须更改它,以便仅将 2 个参数传递给 git
。您只需将 <url>
括起来即可做到这一点通过(双)引号进行参数:
git remote add origin "file://\\some.site.com\projects\fldr\Software Development\Git\thisProject.git"
这是完全合乎逻辑的行为 - 命令和参数由 空格 字符分隔,因此包含此类字符的任何单个参数都必须用(双)引号括起来。
关于git - "git remote add origin"仅显示 "git remote add"的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35615456/