Git is a free and open source distributed version control system for agile and efficient processing of any small or large project.
⒈Install dependent libraries and compilation tools
1. Install dependent libraries
yum install curl-devel expat-devel gettext -devel openssl-devel zlib-devel
2. Install compilation tools
yum install gcc perl-ExtUtils-MakeMaker
⒉Download and install Git
1. Create a new download directory
Choose a directory to put the downloaded installation package, and place the installation package here /usr/local/src directory
cd /usr/local/src
2. Go to the official website to find a new stable version Download the source code package to the /usr/local/src
folder (I am currently at 2.22 here)
wget https://mirrors. edge.kernel.org/pub/software/scm/git/git-2.22.0.tar.gz
3. Decompress and compile
ⅰUnzip p>
tar -zvxf git-2.22.0.tar.gz
ⅱ compile
cd git-2.22.0/ enter the unzipped directory
make all prefix=/usr/local/git execute compilation
ⅲAfter the compilation is completed, install it under the /usr/local/git directory
make install prefix=/usr/local/git
⒊Configure Git
1. Configure environment variables
ⅰAdd the git directory to the PATH
change the original PATH to the current directory
echo'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
ⅱ Make the updated environment variable Effective
source /etc/bashrc
ⅲTest whether the environment variable is effective
git --version
At this point, we can check the git version number, indicating that we have successfully installed it.
2. Create a git account password
ⅰCreate an account
Create an account for the git we just built
useradd -m fanqi
ⅱCreate a password
Then set a password for this account (the system asks for a password after entering the command, and enter the password twice in a row Can be created)
passwd fanqi
3. Initialize the git repository and configure user permissions
ⅰ create git warehouse and initialize it
we create /data/repositories directory to store git warehouse
mkdir -p /data/repositories create a directory
cd /data/repositories/ && git init --bare test.git enter this directory and initialize this repository
ⅱConfigure user permissions
< p> set users and user groups and set permissions for the git warehouse directory
chown -R fanqi:fanqi /data/ repositories
chmod 755 /data/repositories
ⅲChange the git shell to git-shell
⑴Find the directory where git-shell is located
p>
If you follow the steps just now, the location should be /usr/local/git/bin/git-shell, otherwise, please check the location through the which git-shell
command
⑵Edit the /etc/passwd file, and change the last line of the login shell configuration of gituser
to the git-shell directory (for security purposes, restrict the ssh connection of the git account to only log in git- shell)
fanqi:x:500:500::/home/fanqi:/usr/local/git/bin/git-shell
ⅳ Use the built Git service to clone the test repo to the local
cd ~ && git clone [email Protected]:/data/repositories/test.git
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
cd /usr/local/src
wget https://mirrors.edge .kernel.org/pub/software/scm/git/git-2.22.0.tar.gz
tar -zvxf git-2.22.0.tar.gz pre>cd git-2.22.0/ enter the unzipped directory
make all prefix=/usr/local/git execute compilationmake install prefix=/usr/local/gitp>
echo'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
source /etc/bashrcgit --versionuseradd- m fanqipasswd fanqimkdir -p /data/ repositories create directories
cd /data/repositories/ && git init --bare test.git enter this directory and initialize this repositorychown -R fanqi:fanqi /data/repositories
chmod 755 /data/repositoriesfanqi:x:500:500::/home/fanqi:/usr/local/git/bin /git-shellcd ~ && git clone [email protected]:/data/repositories/test.git