UNC 路径上的 git

发布于 2024-10-17 09:36:08 字数 340 浏览 1 评论 0原文

我的电脑装有Windows XP,没有互联网连接,只能访问网络驱动器。我想在网络驱动器上设置一个 git 存储库,然后从本地存储库推送到它,这样我就可以在一天结束时转到具有 Internet 连接的计算机并从网络驱动器推送到 github。

我的问题是我无法从 git 访问网络驱动器。我将 PortableGit 放在网络驱动器上,但 git-bash.bat 和 git-cmd.bat 因“CMD 不支持 UNC 路径作为当前目录”而死亡。我尝试在 git-cmd.bat 中将“cd”替换为“pushd”,但它不起作用。

顺便说一句,我使用 PortableGit 因为我的机器没有管理员权限。

有什么想法吗?

I have computer with Windows XP and no Internet connection, only access to network drive. I'd like to set up a git repository on the network drive and then push to it from my local repository, so I can at the end of the day go to a computer with Internet connection and push from network drive to github.

My problem is I cannot access network drive from git. I put PortableGit on the network drive, but git-bash.bat and git-cmd.bat die with "CMD does not support UNC paths as current directories.". I tried replacing "cd" with "pushd" in git-cmd.bat, but it doesn't work.

BTW, I use PortableGit since I don't have admin permissions on my machine.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

黒涩兲箜 2024-10-24 09:36:08

这对我有用:

git.exe clone "d:/dev/SDK" "//comp1/Proj/git/SDK/"

This worked for me:

git.exe clone "d:/dev/SDK" "//comp1/Proj/git/SDK/"
最佳男配角 2024-10-24 09:36:08

只需使用 UNC 路径 - git 不关心 cmd 可以做什么和不能做什么。


旧答案:将 UNC 路径绑定到驱动器号(或使用目录符号链接)。

Just use the UNC path - git doesn't care what cmd can and cannot do.


Old answer: Bind the UNC path to a drive letter (or use a directory symlink).

邮友 2024-10-24 09:36:08

首先打开 Windows 控制台,运行 -> cmd

pushd \\172.158.1.254\network_usb

现在您应该能够“cd”驱动器上的所有目录。您也可以选择输入
git init --bare nameOfnewRepo.git 某处。

popd

现在打开 git bash 并 cd 到网络驱动器上要克隆存储库的位置

git clone //172.158.1.254/network_usb/pathto/nameOfnewRepo.git

请注意,在 git bash 中斜杠向前,在 Windows 控制台中向后。

First open a windows console, Run->cmd

pushd \\172.158.1.254\network_usb

now you should be able to 'cd' through all the directories on the drive. Optionally you can type a
git init --bare nameOfnewRepo.git somewhere.

popd

Now open git bash and cd to the location where you want to clone the repo on the network drive

git clone //172.158.1.254/network_usb/pathto/nameOfnewRepo.git

Note that in git bash the slashes are forward and in the windows console backward.

幸福%小乖 2024-10-24 09:36:08

正如 Konstantin 所说,“//comp1/Proj/git/SDK/”作为 UNC 路径可以正常工作。

其他人提到使用远程文件系统的性能很差,我无法重现。通过加密的 VPN 文件系统访问克隆相同的存储库需要 3 分钟 45 秒,通过未加密的 HTTP(Bonobo Git 服务器)克隆相同的存储库需要 3 分钟 25 秒。
用于存储库访问的安全通道 + Windows 身份验证当然值得额外支付 10%。

请注意,Cygwin 的“git”命令不适用于此远程路径。与 GitExtensions 捆绑在一起的 git.exe 可以正常工作,VS2015 也可以正常工作。

As Konstantin said, "//comp1/Proj/git/SDK/" works fine as a UNC path.

Others mentioned poor performance using a remote file system, which I cannot reproduce. Cloning the same repo took 3min45 through encrypted VPN file system access and 3min25 through unencrypted HTTP (Bonobo Git Server).
The secure channel + windows authentication for repo access is certainly worth the extra 10%.

Note that Cygwin's "git" command does not work with this remote path. The git.exe that comes bundled with GitExtensions works fine, VS2015 works fine too.

逐鹿 2024-10-24 09:36:08

msysGit 邮件列表(以及当它处于活动状态时,问题跟踪器)上讨论了类似(但不完全相同)的问题。虽然该问题与 UNC 的“Git bash here”功能有关,但解决方案可能类似。也许其中一些链接可以帮助您找到解决方案:

如果您找到解决方案,请考虑将修复提交回 msysGit 项目:)

There's a similar (but not quite the same) issue discussed on the msysGit mailing list (and back when it was active, the issue-tracker). While that issue is about the "Git bash here"-feature from UNC, the solution might be similar. Perhaps some of these links will help you find a solution:

And if you find a solution, please consider to submit the fix back to the msysGit project :)

白龙吟 2024-10-24 09:36:08

检查您是否确实有权访问本地驱动器。将其安装在那里将是最简单的解决方案。

Check if you actually have access to your local drive. Installing it there would be the easiest solution.

秋千易 2024-10-24 09:36:08

似乎有一个寄存器值允许在 cmd 上使用 UNC 路径。您可以通过在 cmd 上运行以下命令来设置寄存器:

reg add “HKCU\Software\Microsoft\Command Processor” /v DisableUNCCheck /t REG_DWORD /d 0x1 /f

来源

It seems that there is a register value that allows to use UNC paths on cmd. You can set up the register by running this on cmd:

reg add “HKCU\Software\Microsoft\Command Processor” /v DisableUNCCheck /t REG_DWORD /d 0x1 /f

Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文