tags:

views:

8647

answers:

6

Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with:

git daemon

Is there a native Windows option, short of sharing folders, to host a Git service?

EDIT: I am currently using the cygwin install of git to store and work with git repositories in Windows, but I would like to take the next step of hosting a repository with a service that can provide access to others.

+4  A: 

Have you considered using the cygwin layer? See this link.

Clokey
+7  A: 

If you are working in a Windows environment, have you considered Mercurial? It is a distributed version control system like Git, but integrates far more neatly and easily with Windows.

David Arno
It's true that it's much easier to use Mercurial on Windows machines, at least as far as being able to synch repositories is concerned. Not a terribly useful answer if you actually have to use Git though!
Frank Shearar
Also Bazaar works natively on windows; it even has commercial support.
hasen j
+2  A: 

Hi,

You do not need to host a service, you can also create a shared repository on a shared drive. Just create a bare repository. You can clone an existing repo into a shared one using: "git clone --bare --shared [source] [dest]". You can also init a new repository using "git init --bare --shared=all".

Henk

Henk
Yes, you can create a shared repository on a drive, but I will NOT be able to access that repository unless I am on the same network as the repository. The goal of the question is to allow remote access to a repository for a co-worker who is working off-site
Jeff Fritz
+4  A: 

I'm currently using cygwin's ssh daemon on Windows to serve up and allow remote access to my repo. It works quite well, I have complete control over who accesses my repo by their ssh certificates, and the performance blazes, even over remote WAN and VPN links.

Another solution is to use Gitosis. It is a tool that makes hosting repos much easier.

Matthew McCullough
How did you get the git daemon working with cygwin? I have the ssh daemon setup and I've testing logging into my machine via ssh but whenever I try to run the git daemon it just hangs.
Thiru
How did you get gitosis working on windows as there is a bug: http://github.com/res0nat0r/gitosis/issues#issue/1
dalore
A: 

I think what Henk is saying is that you can create a shared repository on a drive and then copy it to some common location that both of you have access to. If there is some company server or something that you both have ssh access to, you can put the repository someplace where you can SCP it back to your own computer, and then pull from that. I did this for my self a little while, since I have two computers. It's a hassle, but it does work.

Ibrahim
+15  A: 

Here are some steps you can follow to get the git daemon running under Windows:

(Prerequisites: Cygwin with the packages git and cygrunsrv installed)

Step 1: Open a bash shell

Step 2: In the directory /cygdrive/c/Cygwin/usr/bin/, create a file named "gitd" with the following content:

#!/bin/bash

/usr/bin/git daemon --reuseaddr --base-path=/git --export-all --verbose --enable=receive-pack

Step 3: Run the following cygrunsrv command to install the script as a service (Note: assumes Cygwin is installed at C:\Cygwin):

cygrunsrv   --install gitd                          \
            --path c:/cygwin/bin/bash.exe           \
            --args c:/cygwin/usr/bin/gitd           \
            --desc "Git Daemon"                     \
            --neverexits                            \
            --shutdown

Step 4: Run the following command to start the service:

cygrunsrv --start gitd

You are done. If you want a test it, here is a quick and dirty script that shows that you can push over the git protocol to your local machine:

#!/bin/bash

echo "Creating main git repo ..."
mkdir -p /git/testapp.git
cd /git/testapp.git
git init --bare
touch git-daemon-export-ok
echo "Creating local repo ..."
cd
mkdir testapp
cd testapp
git init
echo "Creating test file ..."
touch testfile
git add -A
git commit -m 'Test message'
echo "Pushing master to main repo ..."
git push git://localhost/testapp.git master
Derek Greer
Thanks a bunch for this. It worked great and saved me time!
Mario
If I could edit this post, I would add the following:Prerequisites: cygwin with the packages git and cygrunsrv installed.
Mario
Ah, yes. I guess I assumed too much.
Derek Greer
Another note: fully qualify the path to git inside of the gitd shell script. On one of my machines MSYSGit was being started instead of cygwin-git when executing as a windows process. MSYSGit does not support daemon mode so the service failed to start.
Mario
I modified per your suggestion.
Derek Greer
Very useful guide - thanks :)
Walt W