1. 程式人生 > >從入門到棄坑之如何使用github

從入門到棄坑之如何使用github

網址

特點

程式碼管理工具 svn集中式(左圖) git分散式(右圖) 在這裡插入圖片描述

需下載

git bash

指令

開啟 git bash 1.pwd 顯示當前路徑 2.cd / 進入根目錄 3.ls 顯示該路徑下的所有檔案和資料夾名 4.cd~ 進入使用者主目錄; 5.cd - 返回進入此目錄之前所在的目錄; 6.cd … 返回上級目錄(若當前目錄為“/“,則執行完後還在“/";"…"為上級目錄的意思); 7.cd …/… 返回上兩級目錄; 8.mkdir 資料夾名 建立資料夾 9. 建立檔案

複製檔案

1.git clone +地址 複製檔案,注意地址在github的資料庫右邊綠色按鈕Clone or download 點開使用Clone with SSH 然後複製其地址 然後選擇yes 跳出如下:

Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

進行下面操作 2.ssh-keygen -t rsa -C "你的郵箱"

生成公鑰,然後緊跟三次回車顯示

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:LeH87cQie97+NTty8ym0Va1+SU7qu6jzZNii//M9qPk 
[email protected]
The key's randomart image is: +---[RSA 2048]----+ | | | | | . .| | o o o| | S . ..| | ooo ..+ | | .oo+=.O.o| | .+=*o*oO=| | .o=*BXEB=*| +----[SHA256]-----+

根據以上程式碼第六行 /c/Users/Administrator/.ssh/id_rsa.pub.尋找該檔案打開復制貼上至 github–右上角個人資訊–Setting–SSH and GPG keys–右邊New SSH Key 3.git clone +地址 克隆成功顯示

$ git clone [email protected]:clarencexiu/clarencexiu.github.io.git
Cloning into 'clarencexiu.github.io'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 14 (delta 4), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (14/14), 2.94 KiB | 88.00 KiB/s, done.
Resolving deltas: 100% (4/4), done.

(檔案出現在當前路徑下,注意調整路徑控制檔案複製位置) 4.cd 地址 進入複製檔案的地址(可以先用ls確認) 5. 建立檔案 6.git add 檔名 增加需要新增的檔案 7.git status 顯示他的狀態 8.git commit -m "first commit" 提交 9.git push -u origin master 將本地的master分支推送到origin主機