Try   HackMD

Git安裝、GitHub設定同步與GitGraph的使用

tags: github git vscode eclipse tutorials

step 1 打開GitHub

https://github.com/

先註冊GitHub帳號
然後我們要建立一個Repository(大概可以翻譯成'儲存庫'的意思),如下圖

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


點進New之後會看到


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


Repository Name是指你的儲存庫的名稱

Description是指你對此儲存庫的描述,可寫可不寫

Public是你要公開這個儲存庫,所有人透過網路可以看到妳儲存庫的內容物

Private就是不公開,只有你看的到

最後按Create Repository

你在GitHub上的儲存庫就建好了

💡建立好Repository的畫面會像這樣,請留著這個頁面,等一下我們需要用到紅框中的這串文字

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


step 2 確認要同步的資料夾的位置

我的路徑如下 D:\1_iSpan\Java\JavaWorkspace\Test\test
Test是我在本機硬碟內建立的資料夾
test是GitHub上Repository的名字

最好是GitHub上的名字要清楚且意義,就可以省去還要再在本機建一個資料夾(例如上方的test)的步驟。

舉例來說:我GitHub上有iSpan_Project1這個Repository
所以其實我可以直接在D槽操作,clone這個Repository
那檔案路徑就會是D:\iSpan_Project1
清楚! 明瞭!

詳細步驟,請參考下方說明~


step 3 下載git

https://git-scm.com/download/win

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


安裝好Git後,開啟 Git CMD

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


輸入以下的指令

  • cd /d 空一格後,貼上你要同步的資料夾位置
    • cd /d 是window系統的語法
    • mac與linux系統請使用cd 空一格後再貼上資料夾位置
    • 且mac與linux系統的路徑斜線方向是/,而window的路徑則是反斜線\
  • git clone 空一格後,貼上剛剛在GitHub上,建好Repository後顯示的那串url
  • cd 空一格後,切換路徑至Repository資料夾
  • git config user.name空一格後,寫上名字
  • git config user.email空一格後,寫上email
  • user.name和user.email只是用來辨識用,不一定要跟註冊GitHub時一樣

我的指令如下
供參供複製~

cd /d d:\1_iSpan\Java\JavaWorkspace\Test
git clone https://github.com/KikiJin24/test.git
cd test  //此處使用相對路徑來切換位置
git config user.name KikiJin
git config user.email jin991824@gmail.com

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



step 4 開啟 VS Code, 打開左側選單中的Extention,搜尋並下載Git Graph

  • Git Graph

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



step 5 VS Code 設定 auto guess encoding

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

使VScode即時猜測編碼,確保當我忘記檢查就push時,檔案編碼仍然是正確的



step 6 重開 VS Code


step 7 用 VS Code 開啟clone下來的GitHub Repository

Files > Open Folder > 選擇剛剛同步的資料夾,也就是我的test資料夾


完成同步設定!!



補充

Git Graph的作用

可以清楚看到檔案路徑,也能確定自已現在是不是有檔案待push或待pull :+1:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


相關文章連結: