visit our site

Taming The Git-Daemon To Quickly Share Git Repository

In Development, Development process

by Sergii Boiko by September 19, 2013

I was once in a hurry to share GitHub repository with a colleague who didn’t have access to it and we decided to use local git-daemon. However, handling all the little quirks that would make it work took a lot more efforts than just dropping a repository archive via Skype.

From this article you will learn how to easily share read/write access to the local git repository. Additionally, I will share two simple aliases for git that will make this task a real no-brainer for anyone.


Please note that this is an insecure way of sharing access to git repository and should be used only in a friendly LAN-environment. If you need secured solution, consider using SSH-protected way.

Sharing read-only access

Next command shares read access(clone/pull) to any repository in current directory:


  • –export-all – shares all the repositories in a folder from “–base-path” option
  • –base-path=. – daemon looks for repositories in a current directory(“.”)
  • –reuseaddr – allows to restart server quickly
  • –informative-errors – provides cleaner error message for clients
  • –verbose – notifies about each operation with the repository

Sample flow

1) Run git-daemon in directory with your repos:

2) Now clients can clone/pull this repository:

Instead of the “” client should use the IP of your computer.

Sharing push access

Add “–enable=receive-pack” option and git-daemon starts supporting push access:

There is one quirk: client can’t push into your active git branch. Before pushing, user on the server should change the branch, if client wants to push to this branch.

Another option can be for the client to create a new branch and push it to your server. Then you can merge it into a required branch.

Sample flow

1) Run git-daemon in read/write mode:

2) Client clones repository:

3) Client branches-off, makes changes and pushes back new branch:

4) Now on Server you can merge this branch:

Sharing only one repository

If you want to share only some repositories, you’ll need to remove “–export-all” option and create “git-daemon-export-ok” file in .git directory of the appropriate repositories.

Sample flow

1) Create magic file:

2) Run git-daemon without “–export-all” option:

3) Client can’t access non-shared repository:

4) Client can access shared repository:

Making life simpler with aliases

Let’s create git aliases for read-only and read/write sharing. Here is what it should look like in .gitconfig:

Notice “!”-symbol in front of the aliases. This is a way to alias external shell command, and with this trick we can call these commands outside of git repository.

Next commands automatically put these aliases into .gitconfig:

Now with “git serve” you can share read access and with “git hub” – read/write access to our repositories. “git serve” resembles Mercurial “hg serve” which performs exactly the same operation. And “git hub” feels to be just right for read/write sharing, don’t know why.

Once the aliases are added, we can run and see “hub” command in action:

Yay, it works!

That’s it, and as I promised – it’s a real no-brainer to share anything using these magic aliases.

* Railsware is a premium software development consulting company, focused on delivering great web and mobile applications. Learn more about us.
  • Sergii

    Very handy, thanks!

  • Brad

    When my local repo is changed by another user who added me as a remote and pushed changes back to me, I don’t see their changes. Is there a cache or something that needs to be refreshed so that I can see changes pushed to my local repo from remote users? Thanks!

  • I enjoyed reading and studying this post. It was my first time to run git daemon, and you provided an excellent introduction. Thank you!

  • Help anyone? I find git difficult and i hate myself for it.
    $ git clone git://localhost/bar

    Cloning into ‘bar’…

    remote: Counting objects: 3, done.

    remote: Total 3 (delta 0), reused 0 (delta 0)

    fatal: read error: Invalid argument

    Receiving objects: 100% (3/3), done.

    fatal: error in sideband demultiplexer

    • Marco Silva

      Hi Jose, Sorry for the late reply, I just got to use git daemon a few days ago, the way to solve this if your git daemon is running in Windows is to hang the command prompt for it not to output any line (cmd tab->right mouse button->edit->markdown), it’s just a stupid git bug and I think it’s the only workaround for this.

      • Gregxxx

        Is there a way to make the git daemon not output any line without doing the manual steps you wrote? I need the whole thing scripted. thanks.

        • Marco Saraiva

          The git daemon should be, in my oppinion, a temporary fix. You should consider using a proper tool like Gitblit for Windows or Gitlab for Linux to serve your git repository, with these you shouldn’t have any issues

  • Alejandro León Mora

    Thanks excellent help for shared git repositories.

  • Awesome post! Thanks!

  • Sanjul

    Thank you.. It was an excellent article

Signup for our weekly newsletter

Want to get more of Railsware blog?

RSS Feed

We're always ready to help!

Contact us