自建git服務器連接Pycharm系列二:在centos7上搭建git服務器
阿新 • • 發佈:2018-08-14
搭建 str dsc 虛擬 conf char har pat 連接
在自己的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
現在已經變成更改後的版本了。
完成。
自建git服務器連接Pycharm系列二:在centos7上搭建git服務器