您当前的位置: 首页 >  git

ITKEY_

暂无认证

  • 0浏览

    0关注

    732博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Centos安装新版本git

ITKEY_ 发布时间:2021-03-21 21:25:58 ,浏览量:0

使用yum 安装的git版本太低了。

git --version
git version 1.7.1

然后我安装oh my zsh报错如下:

% ./install.sh
Cloning Oh My Zsh...
error: unknown switch `c'
usage: git clone [options] [--]  []

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    --mirror              create a mirror repository (implies bare)
    -l, --local           to clone from a local repository
    --no-hardlinks        don't use local hardlinks, always copy
    -s, --shared          setup as shared repository
    --recursive           initialize submodules in the clone
    --template      path the template repository
    --reference     reference repository
    -o, --origin 
                          use  instead of 'origin' to track upstream
    -b, --branch 
                          checkout  instead of the remote's HEAD
    -u, --upload-pack 
                          path to git-upload-pack on the remote
    --depth        create a shallow clone of that depth

Error: git clone of oh-my-zsh repo failed

上面报错我怀疑是git版本过低导致的。

下载安装git

官方下载页面如下: https://git-scm.com/download/linux

我下载的版本是: https://www.kernel.org/pub/software/scm/git/git-2.31.0.tar.gz

安装依赖make会用到
yum -y install autoconf
yum -y install gcc gcc-c++ libstdc++-devel 
yum install openssl-devel
安装
#解压
tar -zxvf git-2.31.0.tar.gz
cd git-2.31.0
make configure
./configure --prefix=/usr/local/git
make profix=/usr/local/git
make install

这样就安装完成了。

配置环境变量

bash配置文件是~/.bash_profile或者编辑系统环境变量/etc/bashrc

这里以zsh为例(因为我用的是zsh)

vim ~/.zshrc

增加下面一行

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

使环境变量立即生效

source ~/.zshrc
查询git版本
git --version
git version 2.31.0

说明新版本安装完成啦。

报错

git:‘remote-https’ 不是一个 git 命令。参见 ‘git --help’。 如果遇到这个报错,发现重新安装git就可以了,什么原因搞不清楚。

参考文档

https://qiankunpingtai.cn/article/1570870677248?p=1&m=0

关注
打赏
1665243900
查看更多评论
立即登录/注册

微信扫码登录

0.0568s