Build a git server on CentOs

Source: Internet
Author: User

Build a git server on CentOs

First install setuptools

  1. Wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
  2. Tar zxvf setuptools-0.6c11.tar.gz
  3. Cd setuptools-0.6c11
  4. Python setup. py build
  5. Python setup. py install

Install the git software on the server (CentOs) first

  • Yum insatll git

Install gitosis

  1. Git clone git: // github.com/res0nat0r/gitosis.git
  2. Cd gitosis
  3. Python setup. py install

Add User git

Sudo useradd-r-s/bin/sh-c 'git version control'-d/home/git

Set permissions

Mkdir-p/home/git

Chown git: git/home/git

Ssh login verification

  • Cat kailuzhe_rsa.pub> authorized_keys exists, append
  • Mv kailuzhe_rsa.pub authorized_key authorized_keys does not exist, renamed

Generate public key

  • Ssh-keygen-t rsa

Upload Public Key

  • Scp ~ /. Ssh/id_rsa.pub USER @ YOUR_SERVER:/tmp

Generate a management database on the server

  • Sudo-H-u git gitosis-init </tmp/id_rsa.pub

The following prompt indicates that the installation is successful.

Initialized empty Git repository in/var/spool/gitosis/repositories/gitosis-admin.git/Reinitialized existing Git repository in/var/spool/gitosis/repositories/gitosis-admin.git/

Modify upload permission

  • Chmod 755/var/spool/gitosis/repositories/gitosis-admin.git/hooks/post-update

Synchronize configuration files

  • Git clone git + ssh: // git@118.123.16.30: 22000/gitosis-admin.git

Create a new repositories

Open the gitosis. conf file and you will see

[Group gitosis-admin]

Writable = gitosis-admin

Members = nasa127 @ localhost

This is the Management Group permission. The username in members is the username in the uploaded public key. Add the following content to the file:

[Group myteam]

Members = nasa127 @ localhost

Writable = diablo3_spider

Here you define a group named myteam, and grant the user "diablo3_spider" repo permission to nasa127 @ localhost.

Git commit-a-m "Allow nasa write access to diablo3_spider"

Git push

The above operation updates the server's permissions. Create the repo of diablo3_spider.

Mkdir diablo3_spider

Cd diablo3_spider

Git init

Add some file submission code:

Git remote add origin git @ YOUR_SERVER_HOSTNAME: diablo3_spider.git

Git add.

Git commit-a-m "initial import"

Git push origin master: refs/heads/master

Next, you can add the Member's public key to the system.

Cd gitosis-admin

Cp ~ /Administrator@SUNPX-PC.pub keydir/

Cp ~ /Tongzhongqian@localhost.pub keydir/

Git add keydir/Administrator@SUNPX-PC.pub keydir/tongzhongqian@localhost.pub

Modify gitosis. conf

[Group fractalist]

Members = nasa127 @ localhost Administrator @ SUNPX-PC tongzhongqian @ localhost

Writable = GTFund-iPad

Submit changes:

Git commit-a-m "Granted sunpx and qtz commit rights to diablo3_spider"

Git push

Other members can get the code.

Git clone git @ YOUR_SERVER: diablo3_spider.git

Others

Set the port number for Git

Git + ssh: // git @ YOUR_SERVER: PORT/GTFund-iPad.git

Git remote add origin git + ssh: // git @ YOUR_SERVER: PORT/GTFund-iPad.git

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.