2012-08-08

How to install GIT Server on Windows

As you know, GIT is one of source code management system. And it's ability includes a distributed revision control.
If you don't need any central integrated server, use only msysgit.
If you want to control GIT by GUI, use msysgit and TortoiseGIT that is front-end for msysgit.

The following instruction is how to install GIT repository server on Windows.

  • Summary
    • Setup
      • Install Cygwin
      • Setup SSH daemon
      • Add user for GIT service
      • (optional) Install Gitolite for managing accounts
    • Use GIT
      • Create Repository
      • Push project on developer's system
      • Download and install TortoiseGIT and MsysGit
  1. Install Cygwin
    • Download Cygwin installer on cygwin.com
    • Run setup.exe
    • Add [git] in [Devel] and [openssh] in [Net] and [python] in [Python]
  2. Setup SSH
    • Add Environment Variable
      • Select [Properties] on [Computer]
      • Click [Advanced system settings] on Control Panel > System and Security > System]
      • Click [Environment Variables...]
      • Click [New...] on System variables pannel
      • Type [CYGWIN] for [Variable name] and [ntsec] for [Variable value]
      • Click [OK]
    • Run [Cygwin Bash Shell] as Administrator
      • $ ssh-host-config  <= setup sshd
      • Answer [yes] for most questions
      • Answer [no] for question about using a different username for running the service
      • $ cygrunsrv -S sshd  <= run sshd
  3. Add user
    * There are no users in Cygwin that do not exist in Windows first. Create the Windows user first then use mkpasswd to add that user to /etc/passwd.
    • On Control panel
      • Control Panel > User Accounts and Family Safety > Add or remove user accounts
      • Create a new account
    • On command prompt
      • $ net user git password /add /yes
      • $ net localgroup <an_local_group> git /add
      • $ mkpassd -l -u git >> /etc/passwd  <= on Cygwin shell
      • Update git's home directory to /cygdrive/d/git-repository in the file /etc/passwd <= d is hard disk drive
  4. Add public key
    • $ ssh-keygen
    • $ cd .ssh
    • $ cp id_rsa.pub /tmp
    • runas /user:git c:/cygwin/cygwin.bat <= on windows command prompt
    • $ cp /tmp/id_rsa.pub ~/.ssh/authorized_keys
  5. Use Git
    • Create repository
      • login as git
      • $ mkdir PROJECT.git
      • $ cd PROJECT.git
      • $ git --bare init
    • Push project
      * in the project folder
      • git init
      • git add .
      • git commit -m 'initial commit'
      • git remote add origin git@[SERVER_NAME or IP]:PROJECT.git
      • git push origin master
    • Pull project
      • git clone git@[SERVER]:PROJECT.git

No comments:

Post a Comment