--- title: Git 基礎課程 行前提醒 tags: GDSC NCKU --- # Git 基礎課程 行前提醒 ## 軟體安裝 ### VS Code 1. 依據筆電作業系統到 [VS Code官網](https://code.visualstudio.com/) 選擇對應的版本安裝 2. 下載後開啟 VS Code 並點選左側欄的 Extensions 按鈕 ![](https://i.imgur.com/Ujcf86y.png) 3. 搜尋 Git Graph 套件並按下 Install ![](https://i.imgur.com/yCDfqmj.png) 4. 安裝成功後左側欄會多出一個按鈕 ![](https://i.imgur.com/8HVAa8a.png) ### Git 1. 依據作業系統在 [Git官網](https://git-scm.com/) 下載對應版本 2. 在 VS Code 打開終端機,輸入 `git --version` 檢查是否安裝成功 ![](https://i.imgur.com/Oi5qE5Q.png) ![](https://i.imgur.com/p3WZaol.png) - 詳細流程可參考連結 [Windows版](https://w3c.hexschool.com/git/3f9497cd) [Mac版](https://w3c.hexschool.com/git/fd6f6be) ## 初次使用設定 ### GitHub 帳號註冊 - 到 [GitHub](https://github.com/) 註冊帳號並登入 ### 設定個人資料 - 在終端機上進行個人資料的設定 - 輸入姓名:`git config --global user.name "xxxxxx"` - 輸入個人的 email:`git config --global user.email "xxxxxx"` - 查詢 git 設定內容:`git config --list` ,查詢結束輸入`q`即可離開 ### 設定 ssh 連接 1. 在終端機上輸入 `ssh-keygen` 2. 不須輸入任何文字按 Enter 鍵直到出現類似下列的畫面 ``` Generating public/private rsa key pair. Enter file in which to save the key (/Users/niomoo/.ssh/id_rsa): <輸入 Enter 鍵> Created directory '/Users/niomoo/.ssh'. Enter passphrase (empty for no passphrase): <輸入驗證密碼> Enter same passphrase again: <再輸入一次同樣的驗證密碼> Your identification has been saved in /Users/niomoo/.ssh/id_rsa. Your public key has been saved in /Users/iniomoo/.ssh/id_rsa.pub. The key fingerprint is: 57:15:3c:ca:f2:dc:27:6d:c2:9a:88:d0:70:cf:8d:31 niomoo@niomooMBP.local The key's randomart image is: +--[ RSA 2048]----+ | .o. | | .o | | ... . | | . . E.o | | +So.O o . | | . ..+ + = +| | . . . o = | | . . o | | | +-----------------+ ``` 3. 繼續在終端機上輸入指令 `cat ~/.ssh/id_rsa.pub` 4. 將終端機上出現的 `ssh-rsa` 開頭整串文字複製起來 5. 進入 GitHub 的設定頁面 ![](https://i.imgur.com/L6bQJlp.png) 6. 找到左側的 SSH and GPG keys 頁面並點選 New SSH key ![](https://i.imgur.com/jPYexjE.png) 7. Title 輸入你想要的名稱(建議以電腦命名),並在 Key 中貼上剛剛複製下來的公鑰 ![](https://i.imgur.com/SnHlLcr.png) 8. 按下 Add SSH key 就完成了!