GIT server setup tutorial

Git installation

Task duration: 5 to 10 minutes

Git is a free, open source distributed version control system designed to handle any project, small or large, with agility and efficiency.

This experiment takes CentOS 7.2×64 system as the environment to set up git server.

Install dependent libraries and build tools

In order for the subsequent installation to proceed properly, we will first install some dependent libraries and compilation tools

Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

Yum install GCC perl- extutils-makemaker

Select a directory to store the downloaded installation package. In this case, place the installation package in the /usr/local/src directory

Run the /usr/local/src command to download a new stable source file from the /usr/local/src directory

Wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz decompression and compilation

Unzip the downloaded source package

Tar -zvxf git-2.10.0.tar.gz is decompressed and the git-2.10.0 folder is displayed

CD Git-2.10.0 Perform compilation

Make all prefix=/usr/local/git After compiling git, install git to /usr/local/git

Make install prefix=/usr/local/git to configure environment variables

Task duration: 5 to 10 minutes

Add git directory to PATH

Change the PATH to the current directory

Echo ‘export PATH=$PATH:/usr/local/git/bin’ >> /etc/bashrc Takes effect environment variables

Source /etc/bashrc Git installation is successful.

Git –version Specifies the password for creating a Git account

Task duration: 5 to 10 minutes

Creating a Git Account

Create an account for the Git we just set up

Useradd -m gituser then sets the password for this account [?]

passwd gituser

Console after entering the create password, enter your custom password and confirm again.

Initialize the Git repository and configure user permissions

Task duration: 5 to 10 minutes

Create and initialize the Git repository

We created the /data/ Repositories directory to house the Git repository

Mkdir -p /data/repositories Once created, initialize the repository

CD /data/repositories/ && git init –bare test

Set up users and user groups and permissions for the Git repository directory

Gituser :gituser /data/repositories chmod 755 /data/repositories chown -r gituser:gituser /data/repositories Change the last line about the login shell configuration for gituser to the git-shell directory [?] The following

Example code: /etc/passwd

gituser:x:500:500::/home/gituser:/usr/local/git/bin/git-shell

If you followed the previous steps, the location should be /usr/local/git/bin/git-shell, otherwise check the location using the which git-shell command

For security purposes, the SSH connection of a Git account can only be used to log in to git-shell

Use the established Git service

Clone the test repo locally

CD ~ && git clone gituser @ < your CVM IP address > : / data/repositories/test. The git experiment

Congratulations, Git server setup is complete. Now you can easily submit your native code to Git server for hosting