1. Install git
(1) Install dependent libraries
#yum-y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
In order to be able to add more formats to a document (such as doc, HTML, info), you need to install the following dependency packages:
#yum-y install AsciiDoc Xmlto docbook2x
(2) Install Git
Yum Online Installation
#yum-y install git
(source installation)
#tar-ZXF git-2.x.x.tar.gz
#cd git-2.x.x
#./configure
#make && make Install
Summary command:
#yum-y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x git
2. Create user
(1) Setting up users and Groups
#adduser git
#passwd git
Git
Summary command:
#adduser git && passwd git
3. Create a certificate Login
Collect the public key of all users who need to log in, the public key is in the Id_rsa.pub file, import into the/home/git/.ssh/authorized_keys file, one line at a.
(if it is not created by the file)
#su-git ($pwd/home/git/)
$mkdir. SSH && chmod. ssh
$touch. Ssh/authorized_keys && chmod. Ssh/authorized_keys
Summary command:
#su-git
$mkdir. SSH && chmod. SSH && touch ssh/authorized_keys && chmod. Ssh/authorized_keys
4. Add public key, create certificate Login
The server administrator adds the public key to the GIT user's Authorized_keys file.
#cat rsa.pub >>/home/git/.ssh/authorized_keys
5. Initialize the GIT repository
Create a directory (/home/git/project.git) where you want to store your development projects under your Git account, usually ending with. Git, and then creating a bare repository as the Project remote Repository, which completes the GIT server build
(The project folder will be generated when someone else git clone)
#su-git
$mkdir Project.git
$CD Project.git
$git Init--bare (--shared automatically give write permissions to the project folder)
Summary command:
#su-git
$mkdir project.git && cd project.git && git init--bare
6. Add Items
#cd/data/git
#git Init
#git Add *
#git commit-m "Initial commit"
#git remote Add origin [email protected]:/home/git/project.git (need to enter git password)
#git Push Origin Master
Summary command:
Git init && git add * && git commit-m "Initial commit" && git remote add origin [email protected ]:/home/git/project.git && git push Origin master
7. Disable git user login via shell
Edit/etc/passwd file, change/bin/bash to/usr/bin/git-shell
Now git users can only use SSH connections to push and get the Git repository, rather than using the host shell directly.
If you need to add a public key, you need to do it with the root user.
Note Before each push project, you should first git pull
This article is from the "three degree" blog, be sure to keep this source http://6207455.blog.51cto.com/6197455/1737703
Git server-side configuration