23

I have a small company, for managing project I want run a git server in my company (local). How can I install git server on our local windows server?

I want my programmers can use git commands to connecting to this server.

MajAfy
  • 3,007
  • 10
  • 47
  • 83
  • 3
    Did you read the manual? http://git-scm.com/book/en/Git-on-the-Server – Daniel Jan 28 '14 at 15:12
  • 3
    Thanks Daniel, but this manual is for linux, I want install on Windows Server 2008 – MajAfy Jan 28 '14 at 15:16
  • 1
    It is pretty much the same for windows, just install the same Git client on your server as your team is using and you should be good to go. – Daniel Jan 28 '14 at 15:17
  • The `git` client is cross platform. It works on Linux and Windows. If you search on stackoverflow and in the manual, you will find the command `git daemon` use that to host your git server or there are projects such as `gitlab` or `stash` that can provide an interface like github. – First Zero Jan 28 '14 at 15:40

1 Answers1

37

I assume you already have your local Git set up. For that, there are plenty of resources on the Internet, including this blogpost about Windows Git tooling.

The entire tricks works like this – expose folder containing your shared Git repository as Windows network share.

Step one – bare git repository

There are two twists to the entire solution – one of them is – your shared repository needs to be initialized with --bare flag.

enter image description here

Step two – Windows share

Second step is to expose the folder with our newly created repository on the Windows share. You also use your standard Windows mechanisms to control and limit access to the folder (make sure you give the developers write access!).

Step three – Map the share as network drive

This step is perhaps not exactly necessary but I couldn’t get it to work otherwise, so here comes the second twist. In order for your developers to be able to access the shared folder via Git they need to map it as network drive.

enter image description here

Step four – Add remote repository in Git and code away

Last step is the standard Git procedure – every developer on your team needs to add the repository sitting under their newly created network drive as remote. Notice the use of “file:///” prefix in front of the mapped drive name.

enter image description here

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • 8
    +1 *finally* a tutorial that got GIT working for me! Just to add to this, you don't have to map the actual repository folder, you could map to the drive root for example and get to the repository subfolder such as `file:///n:/subfolder/subsubfolder` etc and also use a `\ ` to escape spaces in folder names e.g. `as file:///n:/sub\ folder/sub\ sub\ folder`. Also this only seems to work in MINGW and not in CMD.exe which doesn't let me `cd` to mapped network drives – Dan Sep 18 '14 at 06:35
  • and what happens when two users try to push at the same time? – Robert Ivanc Dec 18 '14 at 14:49
  • 3
    Then the universe explodes. @RobertIvanc – Black May 09 '16 at 13:56
  • 1
    works with me without network driver map, I just uses `git remote add origin file:///c:/gitrepo/projectname`, then all good, thanks so much~ – Ariex Jun 21 '16 at 23:31
  • what software do I need on the server, and on the develoment computers ? – GuidoG May 11 '21 at 11:26