简体   繁体   English

如何从局域网内的其他电脑git克隆窗口中的repo?

[英]How to git clone a repo in windows from other pc within the LAN?

I have this git repo "c:/xampp/htdocs/ * *" in my main PC and its IP address is 192.168.0.6. 我在我的主PC上有这个git repo“c:/ xampp / htdocs / * *”,其IP地址是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. 现在我想从我的主PC上的Vmware Player上运行的ubuntu-server git克隆这个repo。

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. 来自ubuntu-server并且都没有工作。

fatal: could not create work tree dir '****'.: Permission denied

What did I wrong? 我错了什么? what should I do? 我该怎么办?

You should use the command git daemon to host your repo, like this: 您应该使用命令git daemon来托管您的仓库,如下所示:

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) (请注意, path_to_folder_containing_project是包含项目文件夹的文件夹,它将提供该文件夹下的所有项目)

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. 克隆的repo的原点将指向LAN中的服务器,因此您可能希望使用git remote set-url origin将其指向原始源。

You may want to run git daemon with the --verbose option to get more details in case you run into problems. 您可能希望使用--verbose选项运行git daemon ,以便在遇到问题时获取更多详细信息。

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 on 192.168.0.6 . 要访问存储库,您必须在192.168.0.6上共享它,或者必须与在192.168.0.6上拥有该文件的域用户相同。

If you share the directory on 192.168.0.6 (eg with share name myrepo ), you access it with //192.168.0.6/myrepo . 如果您在192.168.0.6上共享目录(例如,使用共享名称myrepo ),则可以使用//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: 如果您使用192.168.0.6上已知的用户帐户登录到您的邮箱,则可以尝试通过管理共享访问存储库:

//192.168.0.6/c$/xampp/htdocs/...

Always use forward slashes. 始终使用正斜杠。

Another alternative would be using SSH to access the remote machine. 另一种方法是使用SSH访问远程机器。

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: 确保您的c:/ xampp / htdocs文件夹(或其子文件夹)在Windows中共享,因此您可以通过以下地址在网络上导航:

\\192.168.0.6\htdocs

Then you clone by using file:////. 然后使用file:////进行克隆。 Note that there are four slashes: 请注意,有四个斜杠:

git clone file:////192.168.0.6/htdocs/somerepo.git

To make git repo on Windows local network you'd need to do the following: 要在Windows本地网络上创建git repo,您​​需要执行以下操作:

  1. Create new repo 创建新的回购

    git init --bare projectName.git git init --bare projectName.git

  2. Share this folder (projectName.git) with the users you need 与您需要的用户共享此文件夹(projectName.git)

  3. Find your PC ip with ipconfig command (eg 192.168.2.101) 使用ipconfig命令查找您的PC ip(例如192.168.2.101)
  4. Run this command from some user's machine 从某个用户的计算机运行此命令

    git clone //192.168.2.101/projectName.git 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 (eg //192.168.2.101/some/path/projectName.git) 注意:在finder中打开\\\\ 192.168.2.101以查看projectName.git的正确路径(例如//192.168.2.101/some/path/projectName.git)

Using explorer (smb) to mount the remote repository as a network share is the easiest way. 使用资源管理器(smb)将远程存储库作为网络共享安装是最简单的方法。 I'm not entirely sure, but I think you paths might be wrong. 我不完全确定,但我认为你的道路可能是错的。 Try file:///192.168.0.6\\c:\\xampp... instead. 请尝试file:///192.168.0.6\\c:\\xampp...而不是。

There are two things that might have gone wrong for you: 有两件事可能会对你造成错误:

  • You don't have read permission on the remote repository 您没有远程存储库的读取权限
  • You don't have write permission in the location you want to create your repository ( the current working directory or the directory you specify as second argument to git clone) 您在要创建存储库的位置(当前工作目录或您指定的目录作为git clone的第二个参数)没有写入权限

And also check if your samba server works for normal file access. 并检查您的samba服务器是否适用于正常文件访问。

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. 我最近在尝试将远程PC中的存储库克隆到同一LAN网络中的本地PC时遇到此错误。 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. 解决方案是首先确保远程PC中的驱动器位置具有本地PC的正确访问权限(读/写 - 可以使用Windows共享选项设置)复制远程存储库的路径。 In your local pc paste the path in a windows explorer window. 在本地PC中,在Windows资源管理器窗口中粘贴路径。 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. 现在,您应该获得主机名和正确克隆URL格式的链接。 Use this link to clone the repository in the local pc. 使用此链接克隆本地pc中的存储库。

Hope this helps. 希望这可以帮助。 Cheers. 干杯。

"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". “我在家里使用了几台不同的计算机 ,我想设置GIT,我可以从任何一台计算机上访问我的代码。我花了一些时间,因为我太习惯使用客户端 - 服务器模型了将一台机器指定为存放存储库的“服务器”,其他一切都是客户端。相反,GIT似乎更像是一个合并工具,每个本地副本都是它自己的“主机”。一旦我明白了,它就证明了设置GIT非常简单,只需要GIT本身和SSH“。

To read more you can check this link: http://blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html 要了解更多信息,请访问以下链接: http//blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM