UNC 路径上的 git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4998549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git on UNC path
提问by dijxtra
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.
我有一台装有 Windows XP 且没有 Internet 连接的计算机,只能访问网络驱动器。我想在网络驱动器上设置一个 git 存储库,然后从我的本地存储库推送到它,这样我就可以在一天结束时去一台有 Internet 连接的计算机并从网络驱动器推送到 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.
我的问题是我无法从 git 访问网络驱动器。我把 PortableGit 放在网络驱动器上,但是 git-bash.bat 和 git-cmd.bat 死了,“CMD 不支持 UNC 路径作为当前目录。”。我尝试在 git-cmd.bat 中用“pushd”替换“cd”,但它不起作用。
BTW, I use PortableGit since I don't have admin permissions on my machine.
顺便说一句,我使用 PortableGit,因为我的机器没有管理员权限。
Any ideas?
有任何想法吗?
采纳答案by Tobias Kienzler
Just use the UNC path - git
doesn't care what cmd
can and cannot do.
只需使用 UNC 路径 -git
不关心cmd
可以做什么和不能做什么。
Old answer: Bind the UNC path to a drive letter (or use a directory symlink).
旧答案:将 UNC 路径绑定到驱动器号(或使用目录符号链接)。
回答by Konstantin Tenzin
This worked for me:
这对我有用:
git.exe clone "d:/dev/SDK" "//comp1/Proj/git/SDK/"
回答by CodeKid
First open a windows console, Run->cmd
首先打开一个windows控制台,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.
现在您应该可以通过“cd”驱动器上的所有目录。您可以选择在git init --bare nameOfnewRepo.git
某处键入 a
。
popd
Now open git bash and cd to the location where you want to clone the repo on the network drive
现在打开 git bash 和 cd 到你想要在网络驱动器上克隆 repo 的位置
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.
请注意,在 git bash 中,斜线是向前的,而在 Windows 控制台中是向后的。
回答by user2667767
As Konstantin said, "//comp1/Proj/git/SDK/" works fine as a UNC path.
正如康斯坦丁所说,“//comp1/Proj/git/SDK/”作为 UNC 路径工作正常。
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%.
其他人提到使用远程文件系统时性能不佳,我无法重现。通过加密的 VPN 文件系统访问克隆同一个 repo 需要 3min45,通过未加密的 HTTP(Bonobo Git 服务器)需要 3min25。用于 repo 访问的安全通道 + Windows 身份验证当然值得多出 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.
请注意,Cygwin 的“git”命令不适用于此远程路径。与 GitExtensions 捆绑在一起的 git.exe 运行良好,VS2015 也运行良好。
回答by thor9216
回答by e18r
Check if you actually have access to your local drive. Installing it there would be the easiest solution.
检查您是否确实可以访问本地驱动器。在那里安装它是最简单的解决方案。
回答by kusma
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:
在 msysGit 邮件列表上讨论了一个类似(但不完全相同)的问题(当它处于活动状态时,问题跟踪器)。虽然该问题与 UNC 的“Git bash here”功能有关,但解决方案可能类似。也许其中一些链接将帮助您找到解决方案:
- http://groups.google.com/group/msysgit/browse_thread/thread/1267781387a4c080
- http://code.google.com/p/msysgit/issues/detail?id=535
- http://groups.google.com/group/msysgit/browse_thread/thread/1267781387a4c080
- http://code.google.com/p/msysgit/issues/detail?id=535
And if you find a solution, please consider to submit the fix back to the msysGit project :)
如果您找到解决方案,请考虑将修复提交回 msysGit 项目:)