Search code examples
gitcygwinmsysgit

Git on windows, is it truly distributed?


I am just starting out with git on the Windows platform. I have mysygit installed and bar a few hiccups I am 'git'ing away nicely.

However, I must be missing something because I don't understand how two msysgit clients on different Windows machines can push and pull to each other directly?

I am a complete linux noob but I think I can see that the ssh thing allows distribution on linux. However, the msysgit client appears just to be additional commands in the windows cmd prompt and there is no windows service element.

If I try git clone 'MyMatesPc' who is going to be listening to this request at the other end?

I can see that if you have a 'central' server running git on linux (or cygwin), you can share commits by pushing them onto the 'central' repo from one machine, then pulling them down onto another.

This effectively means that you are having to use a central server.

I don't have a problem with this, but wanted to check that I am not missing anything!


Solution

  • You can use the local protocol: a simple shared path is enough for two Git repositories on two PC on the same LAN to push/pull from each other.
    No need (in this case) for a "central" server.


    As Noel Kennedy points out in the comments, he had to locally map a drive letter to the remote repo before executing: git clone file:///z.
    That is the safest path, since UNC paths are not always supported with some versions of msysgit.

    You can use UNC paths with recent msysgit versions though, like in a Git bash session:

    $ cd /c/temp
    $ git clone //remote-host/share/path/to/repo.git
    

    (note the '/' instead of the Windows '\')

    In a DOS session, after adding the mingw/bin path, it might work too (i.e. using an UNC path instead of a mapped drive)

    C:\temp>set PATH=%PATH%;c:\msysgit\bin;c:\msysgit\mingw\bin
    C:\temp>git clone \\\\remote-host\\share\\path\\to\\repo.git
    

    Update August 2014 (4 years later), Git 2.1

    Commit c2369bd by Eric Sunshine and Cezary Zawadka (czawadka) means a simpler UNC path now work:

    Windows: allow using UNC path for git repository

    Eric Sunshine fixed mingw_offset_1st_component() to return consistently "foo" for UNC "//machine/share/foo", cf this thread.

    So this should now work:

    git clone //mymachine/shared/repo.git