Install gitosis in Windows 7 (GIT server in Windows)

Source: Internet
Author: User

Gitosis is a server tool that uses SSH to manage git repositories. It is interesting that the interface for adding users and setting permissions is not a webpage, but a special git repository. You only need to set a project, and then push, gitosis will change the server settings, cool!

In Linux, the installation method is very mature, and there are a lot of Internet Google, while in windows, installation takes a lot of effort, as long as it is sometimes encountered problems, the installation process is detailed below.

The steps are as follows:

  • Download and install cygwin
  • Modify the access permissions of related directories after installation
  • Install the SSH daemon service
  • Open Port 22 required for the above SSH service in Windows Firewall
  • Install and configure Python-setuptools
  • Install and configure gitosis
  • Use gitosis

1) download and install cygwin

1) download the online installation program setup.exe from the official website at http://www.cygwin.com.

2. Run setup.exe with the administrator ID to start cygwin Installation


3) cygwin Installation Process

Click Next to continue


Select "Install from Internet"


Set the installation path of cygwin to root directory and select "all users (recommended )"


Set the path for saving cygwin online downloaded packets to local package directory.


Select "Direct Connection"


Select the image address of the downloaded file and click Next (selecting different addresses will affect the download speed)


Start downloading related data packets


If cygwin is installed for the first time, the following page is displayed. Click OK to continue.


Select the packages that are not included by default, including:

  • Git under the devel category
  • OpenSSH under the. NET category
  • Python under the python classification (here, record the Python version number, which will be used later, for example, 2.6)


Click Next to continue


It's a long download wait Interface


After you click "OK", cygwin will be installed.


2) modify the access permission of the related directories after installation

Go to "Start/all programs/cygwin bash shell", right-click and run "cygwin bash shell" as an administrator, and run the following commands in the command line:

$ chmod +r /etc/passwd 
$ chmod u+w /etc/passwd 
$ chmod +r /etc/group 
$ chmod u+w /etc/group

The operation is as follows:


3) install the SSH daemon service

Execute the following command:

$ ssh-host-config

According to the command prompts, answer: Yes, yes, yes, ntsec tty, no, yes, [Password], [repeated Password], refer to the following:

(Note the partial answer in the figure)


So far, the SSH service has been installed!

Open the windows command line and run"> Net start sshd"Start the SSH service (you can also start it in the Windows Service ).

4) open port 22 required for the above SSH service in Windows Firewall

Go to control panel/system and security/Windows Firewall/Advanced Settings (on the Left bar) and add new inbound rules:






The name can be modified based on your preferences.

5) install Python setuptools

First, set the access permission for the python path to ensure that all users can access it:

$ chmod +r /lib/python2.6/ -R

2.6 is the version number of the python to be installed. It must be the version number you have installed. It is 2.6 When I installed it. If you forget it, you can enter "$ Python-V" on the cygwin command terminal to view the information.

Go to the python package index home page to download the corresponding version of Python setuptools, such as version 2.6 to download the setuptools-0.6c11-py2.6.egg.

Copy the setuptools-0.6c11-py2.6.egg to the/home/your_user_name directory (you can also copy your own needs to other places, note that the following running path is correct ), then run the following command on the cygwin terminal in the directory to install it:

$ ./setuptools-0.6c11-py2.6.egg 

If the following information is output, the installation is successful:

Processing setuptools-0.6c11-py2.6.egg 
Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages 
Adding setuptools 0.6c11 to easy-install.pth file 
Installing easy_install script to /usr/bin 
Installing easy_install-2.6 script to /usr/bin 

Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg 
Processing dependencies for setuptools==0.6c11 
Finished processing dependencies for setuptools==0.6c11 

6) install and configure gitosis

1) run the following command to download the GIT repository of the gitosis management end:

$ mkdir sources 
$ cd sources  
$ git clone git://eagain.net/gitosis.git 

2) After the download is successful, run the following command for initialization:

$ cd gitosis  
$ python setup.py install

This will output a lot of information. If there is no problem, the output information in the last line is similar to "finished processing dependencies for gitosis = 0.2 ".

3) Go to "Control Panel/user account and home security" and add an account named "Git" with a custom password. Select a standard user for the type.

4) run the following command on the cygwin terminal to add the newly added git account to the passwd file of cygwin:

$ mkpasswd -l -u git >> /etc/passwd 

View the passwd file (the last line of the file) in any way you like, and confirm that the GIT account has been added.

5) copy your public key file to the directory "/tmp/id_rsa.pub", and then run "$ chmod 755/tmp/id_rsa.pub" on the terminal to modify the File ACL.

If you do not have the corresponding public key, generate one by yourself. Refer to the "set up SSH keys" Guide on GitHub guide or refer to the internet-based git Development Environment (Windows) "generate the SSH key to be used by git" in 3rd.

6) open a new cygwin terminal as a git user (as shown in, in the start/all programs/cygwin)


Run the following command in the terminal to initialize the Public Key Configuration:


$ Gitosis-init

If you are lucky, you will see the following information after success:




If an error occurs, follow the procedure described in step 1 below.


7) if the following error message is displayed in Step 1:


0 [main] Python 4268 D:/cygwin/bin/python.exe: *** fatal error-unable to remap //? /D:/cygwin/lib/python2.6/lib-dynload/select. DLL to same address as parent: 0x3e0000! = 0x410000




Handle the problem as follows:


Close all currently opened cygwin terminal windows, stop the sshd service, open the windows cmd command line window, switch to the cygwin/bin directory, run the ash command, and the $ command line appears, enter "$/bin/rebaseall" again. If no error message is displayed, click OK. For details, refer to the following:




After the error is handled, restart the sshd service and then perform the preceding step 6th again.


8) switch back to the cygwin terminal window opened as the administrator (if one is closed due to step 2) and run the following command



$ chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update


So far, gitosis has been successfully installed!


7) Use gitosis


1) Check out the GIT repository of the gitosis management end.



$ git clone git@your-server-name:gitosis-admin.git


Create a test repository and configure the access permission.


2) Go to the detected directory gitosis-admin, edit the gitosis. conf file, and add the following information:



[group test]

writable = test

members = your_email_from_ssh_key


Save, submit, and push to the gitosis-admin.git repository.


3. Create an empty directory testin your local directory, put a readme.txt file in it, open the GIT bash terminal, and enter the test directory to run the following command, test. the GIT repository will be automatically created on the server (note that after step 1, the repository cannot be directly "$ git clone" and an error will be reported, you must have a non-empty git repository and push it up ).



$ git add .

$ git init

$ git commit -m init

$ git remote add origin git@your-server:test.git

$ git push origin master


Now you can go to the "cygwin/home/git/repositories" directory and check that the test. Git repository is already there!


The test repository is just a schematic demonstration, and any other git repository operations are similar.


References:


Setting up gitosis on Windows 7


Python.exe: *** fatal error-unable to remap


Improvement of git server software gitosis


Pro git: git permission manager on the server gitosis


Gitosis readme


There is also a git repository management tool called gitolite, written in Perl. I heard that it can control more functions such as branch permissions. If you are interested, refer to the following link in Repository:


Gitolite build git Server


Original: http://rongjih.blog.163.com/blog/static/33574461201121611154627/


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.