Home > Development Tools > git > How to install git for linux source code

How to install git for linux source code

藏色散人
Release: 2021-12-01 16:47:29
Original
6203 people have browsed it

How to install git from Linux source code: 1. Download the git source code and upload it to the Linux server; 2. Log in to the target machine, decompress and install; 3. Install "gcc gcc-c"; 4. Perform the git installation Just order.

How to install git for linux source code

The operating environment of this article: linux5.9.8 system, git version 2.9.5, Dell G3 computer.

How to install git from Linux source code?

Linux installation git/source code installation:

Git installation

I won’t record Windows/Mac OS systems here. Just download the corresponding installation program and install it according to the steps.

Linux installation

Log in to https://git-scm.com/download/linux

Source code installation

1. Download the source code

You can download the source code on another computer and then upload it to the Linux server

https://mirrors.edge.kernel.org/pub/software/scm/git/
Copy after login

to find the corresponding version.

2. Upload to the server

Using git-2.9.5.tar.gz as an example, upload the downloaded file to the server.

scp git-2.9.5.tar.gz  root@192.168.0.102:/home/tools
Copy after login

scp git-2.9.5.tar.gz Target machine user@target machine ip: target machine path

3. Unzip and install

Log in to the target machine, Unzip and install. /home/Git refers to the installation directory

tar -zxvf git-manpages-2.9.5.tar.gz
cd git-2.9.5
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
[root@localhost git-2.9.5]# make && make install
4. ./configure 报错
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/tools/git-2.9.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Copy after login

It can be seen from my Linux server execution error that gcc, cc, cl.exe is no. gcc is the c language compiler for Linux, which means these compilers are not installed on my machine.

Install the following gcc and gcc-c respectively. After successful installation, execute the git installation command

[root@localhost git-2.9.5]# yum install gcc
[root@localhost git-2.9.5]# yum install gcc-c++
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
Copy after login

5. The make command reports an error

[root@localhost git-2.9.5]# make && make install
    * new build flags
    CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:40:18: 致命错误:zlib.h:没有那个文件或目录
 #include <zlib.h>
                  ^
Copy after login

The compilation is interrupted.

make: *** [credential-store.o] Error 1

The zlib header file is missing and the development package is not installed. Install zlib

[root@localhost git-2.9.5]# yum install zlib
[root@localhost git-2.9.5]# yum install zlib-devel
[root@localhost git-2.9.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
[root@localhost git-2.9.5]# make && make install
Copy after login

If no error is reported, the installation is successful

6. Check whether the git installation is completed

Enter the previously specified installation directory and check the git version, it will be successful It means that the git installation is complete

[root@localhost bin]# cd /home/Git/bin
[root@localhost bin]# ./git --version
git version 2.9.5
Copy after login

7. Configure environment variables

vi /etc/profile
Copy after login

Edit the environment variable configuration file, append the following string at the end, and specify the address of the bin directory

export PATH=$PATH://home/Git/bin
Copy after login

After the modification is completed, execute the command to take effect in the configuration file

source /etc/profile
Copy after login

Check whether the configuration is successful. You can switch the path to another directory and execute git --version. Returning to the git version indicates that the environment variable configuration is completed.

Recommended study: "Git Tutorial"

The above is the detailed content of How to install git for linux source code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template