1. 程式人生 > >在Centos 6.4中安裝與配置Git

在Centos 6.4中安裝與配置Git

本文章來自【知識林】

安裝

yum install git

安裝完成後此版本為1.7.1屬於相對較老的版本(如果作業系統的版本相對較高時,git的版本也會較高),對於github、Jenkins等服務都支援不好,所以需要升級git版本。

升級

  • 更新升級作業系統

命令yum update,如果安裝了Docker此類服務,一般都已經執行過yum update了。

  • 安裝相關依賴包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
  • 下載最新版本git(2.9.3)
wget https://github.com/git/git/archive/v2.9.3.zip
unzip v2.9.3.zip
cd git-2.9.3
  • 編譯安裝

將git安裝在/usr/local/git目錄下

make prefix=/usr/local/git all
make prefix=/usr/local/git install
  • 配置環境變數

現在已經完成git新版本的安裝,但使用git –version檢視版本的話依然還是1.7.1,因為環境變數還是之前版本的路徑。

whereis git
git: /usr/bin/git /usr/local/git /usr/share/man/man1/git.1
.gz

可以看到git的所在路徑
只需要修改環境變數值替換掉原始版本/usr/bin/git即可,環境變數配置檔案是:/etc/profile/etc/bashrc

vi /etc/profile

在最後一行加上:
Export PATH=/usr/local/git/bin:$PATH
修改後再應用該配置

source /etc/profile
  • 檢視git版本
git --version
git version 2.9.3

能看到現在的git版本為2.9.3了。

設定git使用者資訊

在設定使用者資訊之前需要先有版本庫的使用者,這裡選擇Github作為版本庫,所以需要先到https://github.com

上註冊使用者資訊。

git config --global user.name “your username”
git config --global user.email “[email protected]

設定好後可以在檢視配置資訊:

more /root/.gitconfig

為Github賬號新增SSH Keys

在github.com上的Settings裡面可以看到SSH and GPG keys的配置,此設定的目的是為了方便訪問Git伺服器時不需要輸入密碼,這樣即方便又更安全。

  • 建立公鑰

ssh-keygen -t rsa -C “[email protected]

這裡輸入自己在github上的郵箱地址,連續按三次回車即可建立完成
建立後公鑰和私鑰都放在~/.ssh目錄下

ll ~/.ssh
-rw-------. 1 root root 1675 828 09:34 id_rsa
-rw-r--r--. 1 root root  400 828 09:34 id_rsa.pub

可以看到id_rsa和id_rsa.pub兩個檔案,第一個是私鑰檔案,第二個是公鑰檔案

  • 檢視公鑰
more ~/.ssh/id_rsa.pub

ssh-rsa ???????== [email protected]

  • 在github上配置公鑰

登入github -> 點選賬號圖示 -> Settings -> SSH and GPG keys -> New SSH key
輸入title值(自己隨便寫,只要方便自己記住是哪臺伺服器的)
貼上從~/.ssh/id_rsa.pub複製過來的公鑰值
點Add SSH key按鈕後要求需要再次輸入登陸密碼,完成後即可建立完成。
剛建立完成的SSH Keys前面的鑰匙是灰色的

  • 測試是否配置成功

在伺服器上輸入:

ssh -T [email protected]

提示:
Are you sure you want to continue connecting (yes/no)?
輸入yes回車,只要顯示 successfully authenticated字眼即表示公鑰配置成功.
此時重新整理github.com網站上的SSH and GPG keys頁面可以看到剛配置的SSH keys前面灰色的鑰匙變數成綠色。

本文章來自【知識林】

相關推薦

Centos 6.4安裝配置Git

本文章來自【知識林】 安裝 yum install git 安裝完成後此版本為1.7.1屬於相對較老的版本(如果作業系統的版本相對較高時,git的版本也會較高),對於github、Jenkins等服務都支援不好,所以需要升級git版本。 升級

Linux CentOS 6.5安裝配置Tomcat-8方法

2. 下載jdk-8u20-linux-x64.rpm,執行rpm -ivh jdk-8u20-linux-x64.rpm安裝;第二步 安裝 tomcat  將apache-tomcat-8.0.0.RC3.tar.gz檔案上傳到/usr/local中執行以下操作:  複製程式碼程式碼如下: [[email&

linux CentOS 6.5 安裝配置JDK-7

系統環境:centos-6.5 安裝方式:rpm安裝 軟體:jdk-7u79-linux-x64.rpm 檢驗系統原版本 [[email protected] ~]# java -version java version "1.7.0_24" OpenJDK Ru

CentOS 6.3安裝配置Tomcat-7方法

安裝說明  安裝環境:CentOS-6.3  安裝方式:原始碼安裝  軟體:apache-tomcat-7.0.29.tar.gz  下載地址:http://tomcat.apache.org/download-70.cgi  wget http://mirrors.hu

CentOS-7.0.安裝配置Tomcat-7的方法

代碼 accept iptables jdk1.7 ews 啟動 state cat 解決方案 轉自:http://www.linuxidc.com/Linux/2015-08/122241.htm 安裝說明 安裝環境:CentOS-7.0.1406安裝方式:源碼安裝

centos 6.4安裝設置apache服務器

sta process vra 關閉selinux 安裝apache tps all cnblogs tar 1.打開虛擬機開啟centos 6.4系統後進入root用戶下,打開終端,輸入#yum -y install httpd,安裝apache服務器。   輸入命令後到

centos 6.4 FTP安裝配置

1: 安裝 檢查是否安裝 [[email protected] ~]# rpm -qa | grep vsftpd  開始安裝 [[email protected] ~]# yum install vsftpd Loaded plugins: faste

centos 6.4安裝cisco vpnclient

tar -zxf vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz #從公司ftp下載 cd vpnclient #給makefile打補丁 wget http://lamnk.com/download/vpnclient-linux-4.8.02-64bit.pat

CentOS-7安裝配置Tomcat8.5

ane dsc 配置 pub add ted tar.gz 分享 cal 第一步:下載Tomcat8.5,通過地址:http://tomcat.apache.org/download-80.cgi下載 最後得到下載文件 apache-tomcat-8.5.15.tar.g

CentOS 7安裝配置JDK8

參考命令:http://www.jb51.net/os/RedHat/73016.html來進行安裝 轉載自:http://blog.csdn.net/czmchen/article/details/41047187 安裝說明 系統環境:centos7 安裝方式:r

CentOS 7安裝配置Tomcat-8方法

命令主要參考http://www.jb51.NET/os/RedHat/73032.html 安裝說明 安裝環境:CentOS-7安裝方式:原始碼安裝 軟體:apache-tomcat-8.0.14.tar.gz下載地址:http://tomcat.apache

CentOS 6.4 iptables 配置詳解

iptables 指令詳解 語法: iptables [-t table] command [match] [-j target/jump] -t 引數用來指定規則表,內建的規則表有三個,分別是:nat、mangle 和 filter,當未指定規

點滴記錄——CentOS 6.4使用virtualenv安裝swift

     virtualenv就是這樣一個工具,它可以在指定位置建立一個擁有獨立安裝目錄的python環境,該隔離環境不會與其他virtualenv環境共享模組。它的具體用法可以參考https://virtualenv-chinese-docs.readthedocs.org/en/latest/,使用vir

Centos6.4下OpenVPN在windows和centos下客戶端安裝配置詳解

上一篇我們介紹了服務端的安裝與配置,我們主要講解在windows下與centos下的配置,ubuntu和android的類似,刷過系統的路由也可以使用openvpn,比如tomato系統,開啟路由器的samba,然後把證書上傳到一個目錄下,然後在openvpn自定義裡面貼

CentOS 6.4編譯安裝GCC 4.8.1 + GDB 7.6.1

在CentOS 6.4中編譯安裝GCC 4.8.1 + GDB 7.6.1  一、編譯安裝gcc 4.8.1 1. 安裝gcc和g++ 新安裝的CentOS缺少編譯環境,必須先安裝舊版本的gcc, 然後再進行自舉編譯 yum -y install gcc  yum -y i

CentOS 6.9 redis安裝基本配置(上)

使用下面的命令進行更新yum源並安裝redis服務: yuminstall -y redis serviceredis start chkconfigredis on 安裝好之後,我們發現一個比較

CentOS 7安裝配置Tomcat-8.5方法

image tomcat -a ava onf cgi 操作 png ble 安裝說明 安裝環境:CentOS-7 安裝方式:源碼安裝 軟件:apache-tomcat-8.5.39.tar.gz下載地址:http://tomcat.apache.org/download-

CentOS 7 FreeRadius + DaloRadius 安裝配置

freeradius daloradius centos7 lamp (1)安裝httpd服務器和MariaDB//安裝Apache和MariaDB數據庫# yum -y update# yum -y groupinstall "Development Tools" # y

CentOS 6.5安裝使用dstat資源統計工具

scripts command inodes ftw entos 閱讀 問題 eth0 fin 目錄 1 dstat 工具的使用 1.1 什麽是 dstat 1.2 dstat 的基本使用 1.2.1 dstat 的默認選項 1.2.2 dstat的常用選項 1.3 檢

HGDB4.3.2在CentOS 6.x安裝和解除安裝指導手冊

目錄 文件用途 詳細資訊 相關文件 文件用途 介紹HGDB4.3.2在CentOS 6.8系統上的安裝和解除安裝流程。 詳細資訊 1.安裝版本及注意事項 1.1 安裝版本 作業系統 CentOS 6.8 x86_64