2015-09-22 58 views
0

我想在Redhat6中安裝git。 我正在關注how to install git本教程。如何在Redhat 6.x/7.x中安裝最新版本的git

# cd /usr/src 
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.5.tar.gz 
# tar xzf git-2.0.5.tar.gz 

# cd git-2.0.5 
# make prefix=/usr/local/git all 
# make prefix=/usr/local/git install 
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc 
# source /etc/bashrc 

# git --version 

我能夠克隆回購和能夠下載git zip文件。 但是當我執行這個命令。

make prefix=/usr/local/git all 

我得到這個錯誤

[[email protected] git-2.0.5]# make prefix=/usr/local/git all 
GIT_VERSION =2.0.5 
* new build flags 
CC credential-store.o /bin/sh: cc: 
command not found make: *** [credential-store.o] Error 127 

如何解決這個問題?

我能夠使用yum install git安裝git。但默認情況下1.7.1正在安裝。但我想上面安裝2

編輯1 當我執行

yum groupinstall 'Development Tools' 

它下載所需的依賴和上面的錯誤消失。

現在,當我執行此make prefix=/usr/local/git all我得到波紋錯誤

CC bulk-checkin.o 
 
In file included from cache.h:4, 
 
       from bulk-checkin.h:7, 
 
       from bulk-checkin.c:4: 
 
git-compat-util.h:213:25: warning: openssl/ssl.h: No such file or directory 
 
git-compat-util.h:214:25: warning: openssl/err.h: No such file or directory 
 
git-compat-util.h:320:25: warning: openssl/evp.h: No such file or directory 
 
git-compat-util.h:321:26: warning: openssl/hmac.h: No such file or directory 
 
git-compat-util.h:323:28: warning: openssl/x509v3.h: No such file or directory 
 
In file included from bulk-checkin.h:7, 
 
       from bulk-checkin.c:4: 
 
cache.h:11:21: warning: openssl/sha.h: No such file or directory 
 
In file included from bulk-checkin.c:5: 
 
csum-file.h:11: error: expected specifier-qualifier-list before ‘SHA_CTX’ 
 
csum-file.h:23: error: expected specifier-qualifier-list before ‘SHA_CTX’ 
 
bulk-checkin.c:96: error: expected declaration specifiers or ‘...’ before ‘SHA_CTX’ 
 
bulk-checkin.c: In function ‘stream_to_pack’: 
 
bulk-checkin.c:128: warning: implicit declaration of function ‘SHA1_Update’ 
 
bulk-checkin.c:128: error: ‘ctx’ undeclared (first use in this function) 
 
bulk-checkin.c:128: error: (Each undeclared identifier is reported only once 
 
bulk-checkin.c:128: error: for each function it appears in.) 
 
bulk-checkin.c: In function ‘deflate_to_pack’: 
 
bulk-checkin.c:193: error: ‘SHA_CTX’ undeclared (first use in this function) 
 
bulk-checkin.c:193: error: expected ‘;’ before ‘ctx’ 
 
bulk-checkin.c:205: warning: implicit declaration of function ‘SHA1_Init’ 
 
bulk-checkin.c:205: error: ‘ctx’ undeclared (first use in this function) 
 
bulk-checkin.c:222: warning: passing argument 3 of ‘stream_to_pack’ makes integer from pointer without a cast 
 
bulk-checkin.c:95: note: expected ‘int’ but argument is of type ‘off_t *’ 
 
bulk-checkin.c:222: error: incompatible type for argument 6 of ‘stream_to_pack’ 
 
bulk-checkin.c:95: note: expected ‘const char *’ but argument is of type ‘enum object_type’ 
 
bulk-checkin.c:222: warning: passing argument 7 of ‘stream_to_pack’ makes integer from pointer without a cast 
 
bulk-checkin.c:95: note: expected ‘unsigned int’ but argument is of type ‘const char *’ 
 
bulk-checkin.c:222: error: too many arguments to function ‘stream_to_pack’ 
 
bulk-checkin.c:237: warning: implicit declaration of function ‘SHA1_Final’ 
 
make: *** [bulk-checkin.o] Error 1

make prefix=/usr/local/git install我得到這個

CC bulk-checkin.o 
 
In file included from cache.h:4, 
 
       from bulk-checkin.h:7, 
 
       from bulk-checkin.c:4: 
 
git-compat-util.h:213:25: warning: openssl/ssl.h: No such file or directory 
 
git-compat-util.h:214:25: warning: openssl/err.h: No such file or directory 
 
git-compat-util.h:320:25: warning: openssl/evp.h: No such file or directory 
 
git-compat-util.h:321:26: warning: openssl/hmac.h: No such file or directory 
 
git-compat-util.h:323:28: warning: openssl/x509v3.h: No such file or directory 
 
In file included from bulk-checkin.h:7, 
 
       from bulk-checkin.c:4: 
 
cache.h:11:21: warning: openssl/sha.h: No such file or directory 
 
In file included from bulk-checkin.c:5: 
 
csum-file.h:11: error: expected specifier-qualifier-list before ‘SHA_CTX’ 
 
csum-file.h:23: error: expected specifier-qualifier-list before ‘SHA_CTX’ 
 
bulk-checkin.c:96: error: expected declaration specifiers or ‘...’ before ‘SHA_CTX’ 
 
bulk-checkin.c: In function ‘stream_to_pack’: 
 
bulk-checkin.c:128: warning: implicit declaration of function ‘SHA1_Update’ 
 
bulk-checkin.c:128: error: ‘ctx’ undeclared (first use in this function) 
 
bulk-checkin.c:128: error: (Each undeclared identifier is reported only once 
 
bulk-checkin.c:128: error: for each function it appears in.) 
 
bulk-checkin.c: In function ‘deflate_to_pack’: 
 
bulk-checkin.c:193: error: ‘SHA_CTX’ undeclared (first use in this function) 
 
bulk-checkin.c:193: error: expected ‘;’ before ‘ctx’ 
 
bulk-checkin.c:205: warning: implicit declaration of function ‘SHA1_Init’ 
 
bulk-checkin.c:205: error: ‘ctx’ undeclared (first use in this function) 
 
bulk-checkin.c:222: warning: passing argument 3 of ‘stream_to_pack’ makes integer from pointer without a cast 
 
bulk-checkin.c:95: note: expected ‘int’ but argument is of type ‘off_t *’ 
 
bulk-checkin.c:222: error: incompatible type for argument 6 of ‘stream_to_pack’ 
 
bulk-checkin.c:95: note: expected ‘const char *’ but argument is of type ‘enum object_type’ 
 
bulk-checkin.c:222: warning: passing argument 7 of ‘stream_to_pack’ makes integer from pointer without a cast 
 
bulk-checkin.c:95: note: expected ‘unsigned int’ but argument is of type ‘const char *’ 
 
bulk-checkin.c:222: error: too many arguments to function ‘stream_to_pack’ 
 
bulk-checkin.c:237: warning: implicit declaration of function ‘SHA1_Final’ 
 
make: *** [bulk-checkin.o] Error 1

而這兩個線

# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc 
# source /etc/bashrc 

執行成功

但是當我鍵入git --version我仍然得到

慶典:在/ usr /斌/ git的:沒有這樣的文件或目錄

+0

你運行配置腳本?檢查'echo $ CC' – hjpotter92

+0

@ hjpotter92當我運行'echo $ CC'或'echo $ cc'時,我得到一個空行 – Varun

回答

3

看起來像/bin/sh: cc: command not found是錯誤消息,它已被分成兩行以增加額外的混淆。即沒有cc命令。

這意味着你需要安裝一個C編譯器。如果你運行以下命令,它應該安裝所有必要的工具(gcc,binutils等)來編譯git。

yum groupinstall 'Development Tools'

您還缺少必要的開發頭,像OpenSSL:已

yum install openssl-devel curl-devel expat-devel gettext-devel zlib-devel 
+0

你能否請檢查上面的錯誤和任何解決方案。不能我下載git文件夾並在.bash_profile中設置主路徑。 – Varun

1

請找臺階下面我也跟着無法上網的系統上安裝的Git

Download the desired tarball from below link, on your PC/Laptop https://www.kernel.org/pub/software/scm/git/ 

我使用了Git-2.8,因爲客戶要求版本> = Git-2.74

Connect to remote Linux system (via winscp or nay other remote connectivity tool). And Place/Move the downloaded git-XXXXXX.tar.gz file on desired location on the linux system where you want to install ‘git’. 
I placed it in Directory: /var/opt/teradata/packages/Package/GIT/ 

From command prompt go to the directory where you placed the above file and run below command to untar the package tar -xvzf git-2.8.0.tar.gz 

CD into the directory that is newly created because of untar command above. cd git-2.8.0/ 

Verify that all the needed files and directories have been uncompressed into the above folder ls -ltr 

Set the Path and Prefix variables with commands below. 

PATH = $ PATH:/var/opt/teradata/packages/Package/GIT/git-2.8.0/usr/bin

PATH = $ PATH:在/ var /選擇/ Teradata數據/包/Package/GIT/git-2.8.0

出口PATH = $ PATH:/var/opt/teradata/packages/Package/GIT/git-2.8.0

化妝前綴=在/ usr /本地/ git all

echo $ CC

Run Below command to check the preinstall configuration checks ./configure 

Run Below command to install. 

使安裝

Now see it work with below command 

的git --version