How to set up git server on local network

Imagine: You want to use git in your small company, but don’t want to store code anywhere like Gihub, GitLab, etc. Of course, you can install something like bonobogitserver, but what if I told you that standard git is enough?!

Yeah, it’s true

Git is everything you need to do this. You can do it on any operation system (I’ll use Windows) — the only difference is turning on network sharing.

Creating server

  • Go to the folder where you want to initialize server. Better give a name without spaces, or you will have to use quotes everywhere later to access to this folder. Moreover, I recommend you to store it in Public folder ( C:\Users\Public)
  • Open any shell that you prefer (I’ll use PowerShell, which can be run by shift + right click, but you can use something else).
  • Type git init <namethatyoulike> --bare in it.

Congrats! You’ve just set up your server! Let’s find out how to connect to it

Connecting to server on the same computer

  • Copy location of your server. Choose where you want to initialize client repository and open shell there. Type git clone <path_to_your_server> in it.
easy peasy lemon squeezy

Note: If you have some problems try to change backslash \ to direct slash /

Congrats! Now you can use this repository as usual git repository and open it with your favorite git GUI client

It’s working!

Connecting to this server from another computer in local network

  • First of all, you need to turn on network discovery. To do this go to Control panel > Network and Sharing Center > Change advanced sharing settings.
  • Furthermore, you can turn off Password protected sharing
  • After going to folder where you have set up server and share it with users that you want to give permission for accessing it Properties > Sharing > Share
  • Also, you better need to turn on sharing in Advanced Sharing Properties > Sharing > Advanced Sharing and give permissions.

You turn on sharing! Now you can send network path to clients.

Note: If they have any troubles with accessing server from other computers — try to experiment with security settings for sharing folders or place server in Public folder ( C:\Users\Public)

  • Now you can connect to server from another computer just go to folder where you want to store client and type git clone <path_to_repository_on_network>
  • If you have got some problems try to use different shell or change backslash \ to direct /

That’s all! Hope this article was useful for you.