Git server-side configuration

Source: Internet
Author: User

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

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.