国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

GitHub in Linux/Ubuntu的配置安裝

2019-11-08 20:12:09
字體:
來源:轉載
供稿:網友
最近萌發了使用github的沖動盡管現階段最大的好處還是將代碼保存到了遠程因為感覺并不會用到分支等等其他功能的樣子

系統版本

$ cat /PRoc/versionlinux version 4.4.0-57-generic (buildd@lgw01-54) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 16.04.1 LTSRelease: 16.04Codename: xenial

安裝git

$ sudo apt-get install git[sudo] username 的密碼:正在讀取軟件包列表... 完成正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 git 已經是最新版 (1:2.7.4-0ubuntu1)。升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 205 個軟件包未被升級。

生成ssh密鑰

$ ssh-keygen -t rsa -C "your_email@email.com"Generating public/private rsa key pair.Enter file in which to save the key (/home/username/.ssh/id_rsa): gitkeyEnter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in gitkey.Your public key has been saved in gitkey.pub.The key fingerprint is:SHA256:YbbASU/RttVk7K4Ks/C0v/y+V7HGIYHoJEw1weZuqJw "your_email@email.com"The key's randomart image is:"an image made up with characters"這里我生成的key取名為gitkey 這樣在你用戶的根目錄(/home/username)下會有一個gitkey.pub的文本文件,里面的內熱就是公鑰,需要用來添加到你在github網站上的賬戶里面還會有一個gitkey的文件,也就是私鑰如果在“Enter passphrase (empty for no passphrase): ”輸入了一個短語,這個是用來對私鑰加密的,即訪問gitkey文件的時候會提示你輸入這個密碼。顯然我是加了密的,所有才會提示“Enter same passphrase again: ”然后需要把這兩個文件cp到/home/username/.ssh/目錄下,終端直接操作(為啥咧?因為這樣才能讓ssh找到。其實還是因為我“擅自”輸入了文件名導致ssh沒有將密鑰直接生成在其默認的目錄下)如果直接一路按回車下來的化,會簡單很多 默認會在/home/username/.ssh/目錄下生成id_rsa和id_rsa.pub文件,即私鑰和公鑰哎找不到這個目錄?隱藏的啦( 即前綴了一個 . )。直接在終端中輸入路徑訪問就可以

設置github賬戶

到github網站上登錄你的帳號settings 里的 SSH and GPG keysNew SSH key (一個綠色的按鈕)Title即標題,最好取一個和當前終端設備(系統)相關的標題方便管理,比如我在window下的密鑰起名為“GitHub for windows”,在這里就取名為“GitHub for Linux/Ubuntu”Key即公鑰,也就是前文中gitkey.pub(默認版:/home/username/.ssh/id_rsa.pub)的內容

測試ssh密鑰

$ ssh -T git@github.com若出現Permission denied (publickey). 個人的解決方法是把這gitkey和gitkey.pub這兩個文件cp到了/home/username/.ssh/目錄下如果生成密鑰那一步是一路回車下來的,就沒發生這個問題若出現Hi YourGitHubName! You’ve successfully authenticated, but GitHub does not provide shell access. 就可以了

簡單使用git

舉一個簡單的例子

1.首先在github網站上創建一個repository,起名叫test

空空如也但是有提示Quick setup — if you’ve done this kind of thing beforeor | HTTPS | SSH | git@github.com:username/test.git即使用git通過ssh來訪問的時候利用git@github.com:YourGitHubName/test.git這個url來訪問你建立的repository

2.終端移動到你的新項目目錄下

$ pwd/home/username/文檔/test$ lstest test.c

3.使用git init初始化git倉庫

$ git init初始化空的 Git 倉庫于 /home/username/文檔/test/.git/

4.使用git add .將所有改動添加到本地倉庫

$ git add .

5.使用git commit -m “commit instruction”來編寫提交說明

$ git commit -m "firt commit"[master (根提交) 2c5bcb7] firt commit 2 files changed, 7 insertions(+) create mode 100755 test create mode 100644 test.c

6.使用git remote add origin git@github.com:YourGitHubName/test.git

盡管還不知道為什么,不過不這樣干沒辦法提交。目前個人的理解是將遠程的repository映射到本地的一個origin上,通過origin進行上傳。日后有更準確的理解會修正。

7.使用git push origin master上傳到遠程上

$ git push origin master對象計數中: 4, 完成.Delta compression using up to 4 threads.壓縮對象中: 100% (4/4), 完成.寫入對象中: 100% (4/4), 2.61 KiB | 0 bytes/s, 完成.Total 4 (delta 0), reused 0 (delta 0)To git@github.com:YourGitHubName/test.git * [new branch] master -> master

8.稍作修改

$ echo asd > asd.txt$ lsasd.txt test test.c

9.提交更新的版本

$ git add .$ git commit -m "second commit"[master c314f60] second commit 1 file changed, 1 insertion(+) create mode 100644 asd.txt$ git push origin master對象計數中: 3, 完成.Delta compression using up to 4 threads.壓縮對象中: 100% (2/2), 完成.寫入對象中: 100% (3/3), 297 bytes | 0 bytes/s, 完成.Total 3 (delta 0), reused 0 (delta 0)To git@github.com:YourGitHubName/test.git 2c5bcb7..c314f60 master -> master

10.下載項目到本地(我這里先刪掉了原本的test目錄)

$ cd ..$ rm -r testrm:是否刪除有寫保護的普通文件 'test/.git/objects/3d/ede79373fd15383d243b9a99f2340111ef2242'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/c3/14f60b58bcd36894c41e37d62b1c228b19021f'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/87/fae94b03488f770ed94496418ff75531904612'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/af/1fa17d50347d23f2a0562b31dca44748ab5858'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/d7/2af314604e3b98e5c108efeb4815c64d2e267b'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/73/9735de9ca4e5ad57f2353ae65a858c4142319b'? yrm:是否刪除有寫保護的普通文件 'test/.git/objects/2c/5bcb7a3b3c768d1007b3f54c33db405fd2f8f0'? y$ cd testbash: cd: test: 沒有那個文件或目錄$ git clone git@github.com:YourGitHubName/test.git正克隆到 'test'...remote: Counting objects: 7, done.remote: Compressing objects: 100% (6/6), done.remote: Total 7 (delta 0), reused 7 (delta 0), pack-reused 0接收對象中: 100% (7/7), 完成.檢查連接... 完成。$ cd test$ lsasd.txt test test.c

更多git的使用

暫無
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浮梁县| 弋阳县| 和平区| 柞水县| 大渡口区| 双江| 邵武市| 阳新县| 寿光市| 亳州市| 尼勒克县| 溆浦县| 晋宁县| 乌兰察布市| 会昌县| 温州市| 孝义市| 基隆市| 泾源县| 尼玛县| 衡山县| 长沙县| 永济市| 墨竹工卡县| 重庆市| 新泰市| 临湘市| 犍为县| 新竹市| 承德县| 黄山市| 天全县| 略阳县| 托克逊县| 南岸区| 德兴市| 柯坪县| 嵊州市| 体育| 湖口县| 广南县|