ubuntu下安裝及配置git的方法


安裝Git

一個全新的ubunt系統,需要安裝Git(系統是不具有該工具的),方法如下:
在terminel中輸入如下命令:

sudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-daemon-run git-el git-arch

接下來需要檢查SSH

因為GitHub會用到SSH,因此需要在shell里檢查是否可以連接到GitHub

ssh -T git@github.com

如果看到:

Warning: Permanently added ‘github.com,204.232.175.90’ (RSA) to the list of known hosts. 
Permission denied (publickey).

則說明可以連接。
這里假設你已經就有了GitHub用戶(如果沒有,需要去注冊GitHub)

安裝SSH keys(一定要在~/.ssh目錄下操作)

在安裝GitHub之前,需要先安裝SSH keys

第一步:檢查是否已井具有ssh keys,如果已經具有,則進行第二步,否則,進行第三步

cd ~/.ssh
ls

第二步:執行如下命令(不具有ssh keys時):

qunzhupu$ ssh-keygen -t rsa -C "984471751@qq.com"

得到結果如下:

qunzhudeMacBook-Air:~ qunzhupu$ ssh-keygen -t rsa -C "984471751@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/qunzhupu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/qunzhupu/.ssh/id_rsa.
Your public key has been saved in /Users/qunzhupu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Rrae8DPfiAIy/KbxJrwBILPH4kkRkklMMxJAeP6LrqA 984471751@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|%@               |
|*.=              |
|++      o        |
|o+o    o .       |
|+oo.  . S        |
|o+= o  = .       |
|.+o= o  *        |
|o ++= .  = o     |
|Eo+*.  .. o .    |
+----[SHA256]-----+

第三步:將剛剛創建的ssh keys添加到github中

  1. 利用gedit/cat命令,查看id_rsa.pub的內容
  2. 在GitHub中,依次點擊Settings -> SSH Keys -> Add SSH Key,將id_rsa.pub文件中的字符串復制進去,注意字符串中沒有換行和空格。
    第五步:再次檢查SSH連接情況(在~/.ssh目錄下):

輸入如下命令:

ssh -T git@github.com

如果看到如下所示,則表示添加成功:

Hi 你的用戶名! You’ve successfully authenticated, but GitHub does not provide shell access.

此時,發現github上已有了SSH keys


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM