linux 源碼怎么安裝git

linux源碼安裝git的方法:1、下載git源碼上傳至Linux服務器;2、登錄目標機器,解壓并安裝;3、安裝“gcc gcc-c++”;4、執行一下git的安裝命令即可。

linux 源碼怎么安裝git

本文操作環境:linux5.9.8系統、git 2.9.5版、Dell G3電腦。

linux 源碼怎么安裝git?

Linux 安裝git/源碼安裝:

Git 安裝

這里就不記錄Windows/Mac OS系統的了,直接下載對應的安裝程序,按步驟安裝即可。

Linux 安裝

登陸https://git-scm.com/download/linux

源碼安裝

1. 下載源碼

可以在另一臺電腦中下載好源碼,然后上傳至Linux服務器

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

找到對應的版本。

2. 上傳至服務器

以git-2.9.5.tar.gz為例,將下載好的文件上傳至服務器。

scp?git-2.9.5.tar.gz??root@192.168.0.102:/home/tools

scp git-2.9.5.tar.gz 目標機器的用戶@目標機器ip:目標機器路徑

3. 解壓并安裝

登陸目標機器,解壓并安裝。/home/Git是指的安裝目錄

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

我的linux服務器執行報錯中看出,gcc,cc,cl.exe為no。gcc是Linux的c語言編譯器,說明我的機器中沒有安裝這些編譯器。

分別安裝以下gcc,gcc-c++,安裝成功之后在執行一下git的安裝命令

[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

5. make命令報錯

[root@localhost?git-2.9.5]#?make?&amp;&amp;?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> ??????????????????^</zlib.h>

編譯中斷。

make: *** [credential-store.o] 錯誤 1

缺少 zlib的頭文件, 開發包沒裝。安裝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?&amp;&amp;?make?install

若無報錯則安裝成功

6.檢查git安裝是否完成

進入之前指定的安裝目錄,查看git版本,能成功則表示git安裝完成

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

7.配置環境變量

vi?/etc/profile

編輯環境變量配置文件,在最后追加下面的字符串,指定bin目錄的地址

export?PATH=$PATH://home/Git/bin

修改完成之后,執行命令,生效配置文件

source?/etc/profile

檢查是否配置成功,可切換路徑到其他目錄中,執行 git –version。返回git版本則表示環境變量配置完成。

推薦學習:《Git教程

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊15 分享