Git Tutorial Server Build Detailed _ Related skills

Source: Internet
Author: User
Tags chmod ssh git clone

Git Server Build

In the previous section, our remote warehouse used Github,github public projects for free, but if you don't want others to see your project, you'll need to charge for it.
Then we need to build a git server to use as a private warehouse.
Next we'll build a Git server as an example of Centos.

1, install Git

$ yum Install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum Install git

Next we create a git user group and user to run the GIT service:

$ groupadd git
$ adduser git-g git

2. Create Certificate Login

Collects the public key of all users who need to log in, the public key is located in the Id_rsa.pub file, and the public key is imported into the/home/git/.ssh/authorized_keys file, one line.

If you do not have the file to create it:

$ cd/home/git/
$ mkdir. SSH $ chmod. SSH $ touch
. Ssh/authorized_keys
$ chmod S


3. Initialize git repository

First we select a directory as a git repository, assuming it is/home/gitrepo/w3cschoolcc.git, and enter the command in the/home/gitrepo directory:

$ cd/home
$ mkdir gitrepo
$ chown git:git gitrepo/
$ cd gitrepo

$ git init--bare w3cschoolcc.git

Ini tialized Empty Git repository in/home/gitrepo/w3cschoolcc.git/

The above command git creates an empty warehouse, and the GIT repository on the server usually ends with. Git. Then, change the user who owns the warehouse to git:

$ chown-r Git:git W3cschoolcc.git

4. Cloning Warehouse

$ git clone git@192.168.45.4:/home/gitrepo/w3cschoolcc.git
cloning into ' W3CSCHOOLCC ' ...
Warning:you appear to have cloned a empty repository.
Checking connectivity ... done.

192.168.45.4 for git's server IP, you need to modify it for your own git service IP.

So our git server Setup is complete, and then we can disable the git user login through the shell, which can be done by editing the/etc/passwd file. Locate a line similar to the following:

Git:x:503:503::/home/git:/bin/bash

To

Git:x:503:503::/home/git:/sbin/nologin

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.