Build a git server on CentOs
First install setuptools
- Wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
- Tar zxvf setuptools-0.6c11.tar.gz
- Cd setuptools-0.6c11
- Python setup. py build
- Python setup. py install
Install the git software on the server (CentOs) first
Install gitosis
- Git clone git: // github.com/res0nat0r/gitosis.git
- Cd gitosis
- 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
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