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

倾然丶 夕夏残阳落幕 提交于 2019-11-26 22:41:33

问题


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?


回答1:


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.

If you share the directory on 192.168.0.6 (e.g. with share name myrepo), 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:

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

Always use forward slashes.

Another alternative would be using SSH to access the remote machine.




回答2:


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.




回答3:


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:

\\192.168.0.6\htdocs

Then you clone by using file:////. Note that there are four slashes:

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



回答4:


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:

  • 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)

And also check if your samba server works for normal file access.




回答5:


To make git repo on Windows local network you'd need to do the following:

  1. Create new repo

    git init --bare projectName.git

  2. Share this folder (projectName.git) with the users you need

  3. Find your PC ip with ipconfig command (e.g. 192.168.2.101)
  4. 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)




回答6:


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.




回答7:


"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



来源:https://stackoverflow.com/questions/5200181/how-to-git-clone-a-repo-in-windows-from-other-pc-within-the-lan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!