温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

自建git服务器连接Pycharm系列二:在centos7上

发布时间:2020-03-11 16:37:13 来源:网络 阅读:858 作者:白话 栏目:软件技术

在自己的Linux虚拟机上,搭建git服务器,用来保存代码。
centos7本身自带git,需要先卸载,安装成较新的版本。

1、卸载系统自带版本

系统已经自带
[root@dscrapy01 ~]# git --version
git version 1.8.3.1

卸载git
[root@dscrapy01 ~]# yum remove git
[root@dscrapy01 ~]# git --version
-bash: /usr/bin/git: 没有那个文件或目录

2、安装指定版本

已经下载tar包版本:git-2.18.0.tar.gz
官网:https://git-scm.com/

安装

解压到指定路径
[root@dscrapy01 setup]# tar -zxvf git-2.18.0.tar.gz -C /home/software/
[root@dscrapy01 setup]# cd /home/software/git-2.18.0/
进入到指定路径进行编译
[root@dscrapy01 git-2.18.0]# ./configure --prefix=/usr/local/git-2.18.0
[root@dscrapy01 git-2.18.0]# make && make install

完成后,需要将git加入到环境变量中

[root@dscrapy01 git-2.18.0]# vim /etc/profile
添加内容:
GIT_HOME=/usr/local/git-2.18.0
PATH=$GIT_HOME/bin
完成后source一下
[root@dscrapy01 git-2.18.0]# source /etc/profile
还要编辑root的non-login的环境变量
[root@dscrapy01 git-2.18.0]# vim ~/.bashrc
添加内容与上面相同
GIT_HOME=/usr/local/git-2.18.0
PATH=$GIT_HOME/bin
完成后source一下
[root@dscrapy01 git-2.18.0]# source ~/.bashrc

注意:一定要修改.bashrc,否则之后从服务器上克隆项目的时候会报错(bash: git-upload-pack: command not found)

3、检验

重新查看git的版本信息

[root@dscrapy01 git-2.18.0]# git --version
git version 2.18.0

现在已经变成更改后的版本了。

完成。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI