Centos7安装git

栏目: 编程工具 · 发布时间: 6年前

内容简介:在Centos上安装软件时,我都是先更新一下系统的yum源,保持yum源是比较新的。下面进入今日的主题,安装git:1.下载源码包

在Centos上安装软件时,我都是先更新一下系统的yum源,保持yum源是比较新的。

yum update

下面进入今日的主题,安装git:

1.下载源码包

查看系统yum源中的git的版本,发现是比较老的版本,于是采用源码包编译安装。

cd /usr/local/src
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz

2.编译安装

cd /usr/local/src
tar -zxvf git-2.9.0.tar.gz 
cd /usr/local/src/git-2.9.0

#安装到 /usr/local/git
./configure prefix=/usr/local/git

make && make instal 报错

[root@iZbp1fuxiq5o2qp7z60ydpZ git-2.9.0]# make && make install
    CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:40:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>

解决方法:

#安装依赖
yum -y install zlib zlib-devel

再次执行make,仍然报错

/usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2

解决办法:

#安装下面的依赖
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker cpan

再次执行make & make install,编译安装成功

3.创建git用户,并将/usr/local/git所属组和所属主修改成git

useradd git

chown -R git:git /usr/local/git

4.将git加到系统环境变量里面

export GIT_HOME=/usr/local/git
export PATH=$GIT_HOME/bin:$PATH

5.初始化仓库

git init --bare mt-front.git

#下面是几种克隆方式
git clone git@xx.xx.xx.xx:/home/git/repository/mt-front.git
git clone ssh://git@xx.xx.xx.xx:/home/git/repository/mt-front.git
git clone http://git@xx.xx.xx.xx:/home/git/repository/mt-front.git

本地clone的时候会报错

  • 提示git-upload-pack命令不存在
bash: git-upload-pack: command not found
#解决
ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack
  • 提示git-receive-pack命令不存在
bash: git-receive-pack: command not found
ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack

7.配置git记住密码,在git的全局配置文件gitconfig文件中添加下面的配置:

[credential]
    helper = store
[user]
    name = nick
    email = nick@da.com

最后更新于 2018-08-03 10:12:52 并被添加「git linux」标签,已有 0 位童鞋阅读过。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Probability and Computing

Probability and Computing

Michael Mitzenmacher、Eli Upfal / Cambridge University Press / 2005-01-31 / USD 66.00

Assuming only an elementary background in discrete mathematics, this textbook is an excellent introduction to the probabilistic techniques and paradigms used in the development of probabilistic algori......一起来看看 《Probability and Computing》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具