如何从局域网内的其他电脑在 Windows 中 git 克隆存储库?
我的主电脑中有这个 git repo“c:/xampp/htdocs/**”,其 IP 地址是 192.168.0.6。现在我想从 ubuntu-server 上 git 克隆这个存储库,该服务器在我的主 PC 上的 Vmware Player 上运行。
我从 ubuntu-server 做了
git clone \\192.168.0.6\c:\xampp\htdocs\****
,
git clone //192.168.0.6/c:/xampp/htdocs/****
但都不起作用。
fatal: could not create work tree dir '****'.: Permission denied
我做错了什么? 我应该怎么办?
I have this git repo "c:/xampp/htdocs/**" in my main PC and its IP address is 192.168.0.6. Now I want to git clone this repo from ubuntu-server which running on a Vmware Player in my main PC.
I did
git clone \\192.168.0.6\c:\xampp\htdocs\****
and
git clone //192.168.0.6/c:/xampp/htdocs/****
from ubuntu-server and neither worked.
fatal: could not create work tree dir '****'.: Permission denied
What did I wrong?
what should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您应该使用命令 git daemon 来托管您的存储库,如下所示:
在将充当服务器的计算机中:
git daemon --base-path=--export-all
(请注意,
path_to_folder_having_project
是包含项目文件夹的文件夹,它将提供该文件夹下的所有项目)在您的客户端中:
git clone git:/ //
克隆的存储库的源点将指向您 LAN 中的服务器,因此您可能需要使用 git remote set-url origin将其指向原始起源。
您可能需要使用
--verbose
选项运行git daemon
来获取更多详细信息,以防遇到问题。You should use the command
git daemon
to host your repo, like this:In your computer that will act as a server:
git daemon --base-path=<path_to_folder_containing_project_folder> --export-all
(please note that
path_to_folder_containing_project
is the folder containing your projects folders, it will provide all projects under that folder)In your client:
git clone git://<local ip>/<project name>
The cloned repo will have its origin pointing to the server in your LAN, so you may want to use
git remote set-url origin
to point it to the original origin.You may want to run
git daemon
with the--verbose
option to get more details in case you run into problems.确保您的 c:/xampp/htdocs 文件夹(或其子文件夹)在 Windows 中共享,以便您可以通过以下地址在网络上导航:
然后使用 file://// 进行克隆。请注意,有四个斜杠:
Make sure that your c:/xampp/htdocs folder (or sub folders of it) is shared in windows, so you can navigate on the network by this address:
Then you clone by using file:////. Note that there are four slashes:
要访问该存储库,您必须在
192.168.0.6
上共享它,或者必须是与192.168.0.6
上拥有该文件的用户相同的域用户。如果您在
192.168.0.6
上共享目录(例如,使用共享名称myrepo
),则可以使用//192.168.0.6/myrepo
访问该目录。如果您使用
192.168.0.6
上已知的用户帐户登录您的盒子,您可以尝试通过管理共享访问存储库:始终使用正斜杠。
另一种选择是使用 SSH 访问远程计算机。
To access the repo, you must either share it on
192.168.0.6
or must be the same domain user as the one that owns the file on192.168.0.6
.If you share the directory on
192.168.0.6
(e.g. with share namemyrepo
), you access it with//192.168.0.6/myrepo
.If you are logged in on your box with a user accout that is known on
192.168.0.6
, you could try accessing the repo through the administrative shares:Always use forward slashes.
Another alternative would be using SSH to access the remote machine.
使用资源管理器(smb)将远程存储库安装为网络共享是最简单的方法。我不完全确定,但我认为你的路径可能是错误的。尝试使用
file:///192.168.0.6\c:\xampp...
代替。您可能有两件事出了问题:
并检查您的 samba 服务器是否可以正常文件访问。
Using explorer (smb) to mount the remote repository as a network share is the easiest way. I'm not entirely sure, but I think you paths might be wrong. Try
file:///192.168.0.6\c:\xampp...
instead.There are two things that might have gone wrong for you:
And also check if your samba server works for normal file access.
要在 Windows 本地网络上创建 git 存储库,您需要执行以下操作:
创建新存储库
git init --bare projectName.git
与您需要的用户共享此文件夹 (projectName.git)
从某个用户的计算机运行此命令
git clone //192.168.2.101/projectName.git
注意:在finder中打开\\192.168.2.101可以看到正确的projectName.git 的路径(例如 //192.168.2.101/some/path/projectName.git)
To make git repo on Windows local network you'd need to do the following:
Create new repo
git init --bare projectName.git
Share this folder (projectName.git) with the users you need
Run this command from some user's machine
git clone //192.168.2.101/projectName.git
Note: open \\192.168.2.101 in finder to see the correct path to the projectName.git (e.g. //192.168.2.101/some/path/projectName.git)
我最近在尝试将远程电脑中的存储库克隆到同一 LAN 网络中的本地电脑时遇到了此错误。
解决方案是首先确保远程电脑中的驱动器位置对本地电脑具有正确的访问权限(读/写 - 可以使用 Windows 共享选项进行设置)
复制远程存储库的路径。在本地电脑的 Windows 资源管理器窗口中粘贴路径。然后复制其目录地址并将其粘贴到任何浏览器中。
现在您应该获得一个包含主机名和正确克隆 URL 格式的链接。
使用此链接将存储库克隆到本地电脑中。
希望这有帮助。
干杯。
I recently ran into this error while trying to clone a repository in a remote pc to a local pc within the same LAN network.
The solution was to first make sure the drive location in the remote pc had the correct access rights for the local PC(Read/Write-which can be set using windows sharing options)
Copy the path of the remote repository. In your local pc paste the path in a windows explorer window. Then copy its directory address and paste it into any browser.
Now you should get a link with the hostname and the correct cloning URL format.
Use this link to clone the repository in the local pc.
Hope this helps.
Cheers.
“我家里有几台不同的计算机,我想设置 GIT,以便我可以从其中任何一台计算机访问我的代码。这花了我一些时间,因为我太习惯使用它了在客户端-服务器模型中,我将一台机器指定为保存存储库的“服务器”,而其他一切都是客户端,相反,GIT 的运行方式似乎更像是一个合并工具,并且每个本地副本都是其自己的“主机”。明白了,原来设置GIT非常简单,只需要GIT本身和SSH”。
要了解更多信息,您可以查看此链接:
http://blog.lazyhacker.com/2010 /04/setting-up-git-for-home-network.html
"I have a few different computers that I use at home and I wanted to set up GIT that I can access my code from any of them. It took me a bit because I was too used to working with a client-server model where I designate one machine as the "server" that holds the repository and everything else was a client. Instead, GIT seems to operate more like a merge tool and every local copy is its own "master." Once I understood that, it turns out that setting up GIT is very simple and just needs GIT itself and SSH".
To read more you can check this link:
http://blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html