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

51,072

Solution 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.

Solution 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.

Solution 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

Solution 4

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)

Solution 5

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.

Share:
51,072

Related videos on Youtube

Kou
Author by

Kou

I'm developing an android app right now.

Updated on May 13, 2020

Comments

  • Kou
    Kou almost 4 years

    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?

  • wgwz
    wgwz over 8 years
    Worked perfectly for me. For clarity you might consider re-phrasing <path_to_projects_folder> as <path_to_folder_containing_project>.
  • tisaconundrum
    tisaconundrum about 5 years
    Thank you for including the --bare parameter, this makes a lot of sense now. My only question is if you've already set up the "remote" repo can you get away with using this command on the "local" machine git clone //192.168.2.101/.git
  • jaques-sam
    jaques-sam almost 5 years
    I got the following issue (even after pruning/updating all branches), after receiving all objects: fatal: read error: Invalid argument & fatal: error in sideband demultiplexer
  • Roberto
    Roberto almost 5 years
  • MTV
    MTV over 4 years
    @tisaconundrum Where is the remote repo? On the network drive or in some folder on the same machine you wish to run git clone?
  • MTV
    MTV over 4 years
    @tisaconundrum If on a network drive, use ping [network drive name] -4 to get the network drive's IP address and then use git clone [networkdriveIP]\\Path\\To\\GitBareRepo from the location you want to clone GitBareRepo into. I'm using windows shell and hence the double backslashes -- substitute them for forward slashes if you're on a unix system.
  • MTV
    MTV over 4 years
    @tisaconundrum If remote repo is on the machine containing the location to which you want to clone that remote repo (i.e., the remote and soon-to-be-created local repo reside on the same machine) use file://C:\\Path\\To\\GitBareRepo.
  • tisaconundrum
    tisaconundrum over 4 years
    Thank you for the assistance @MTV. I ended up answering my own question by trying this. It does make a clone of the repository even when a name is not present at the beginning of the .git
  • legends2k
    legends2k over 2 years
    Pass --base-path=. if just one repo needs to be shared. At the client side don't give any sub-path in the URL; just give a directory name for the cloned repo: git clone git://<LOCAL_IP>/ DIR_NAME (mind the space between / and the directory name).
  • Gilbert
    Gilbert about 2 years
    @MTV thank you very much. I cloned a git repository on windows server like this: git clone \\CompanyServer\Users\Gilbert\Documents\Projects\Myapp myapp-local-copy The entire path can be obtained by navigating to the repository's folder starting from the Networks tab in file manager. The user cloning must also have permissions to that folder. So you can right click the folder, go to properties -> security and add the user.
  • mar10
    mar10 almost 2 years
    Many thanks for that! Worked flawlessly. To be mentioned, for Windows for the "path_to_folder_containing_project" I used the Windows path syntax like "C:/folder1/subfolder2" etc and it worked perfectly. Before actually trying, I was unsure if I need to use a Linux-style or Windows-style path there.