VS code+Github 設定

itsems
itsems_frontend
Published in
Dec 31, 2019
Outline
+ 如何將既有專案 Push 上 Github?
+ Git 環境設定

如何將既有專案 Push 上 Github?

  1. 在 Github 上新增 repository

新增後會出現這樣的頁面

馬賽克是你新增出的 repository 名稱

2. 在專案中建立 Git

到專案資料夾底下,如果是用 VScode,可以直接打開 terminal 下指令:

照著上圖一行一行 key 下指令就可以了

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/itsems/<你的repo>.git
git push -u origin main

環境設定

我自己的 VS code 中的 settings.json 原本就有設定一句

"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",

因為原本都只有用到 Terminal cmd 的用法,如果要在 Terminal 也可以直接輸入 Git 語法使用,要再處理好以下兩種環境:

不確定在安裝 Git 的時候會不會一併設定好,可能是我自己也有再動過系統變數,所以我的系統變數沒有包含 Git 的路徑,以下為 win10 介面系統變數設定:

進入檔案總管後,右鍵「本機」選擇「內容」:

進入內容之後選擇「進階系統設定」並進入「進階」tab,點選「環境變數

在下方的「系統變數」中找到「Path」,點選編輯進入

進入後選擇「新增」,並新增以下兩條路徑:

C:\Program Files\Git\binC:\Program Files\Git\mingw64\libexec\git-core

這邊的路徑是自己安裝 Git 的地方,有可能因安裝位置而異

系統變數如果沒有設定好兩個 Git 的路徑,Terminal 會無法執行 Git 語法,出現「’git’ 不是內部或外部命令、可執行的程式或批次檔。

新增好路徑之後,如果原本 VS code 有開著,要重新啟動,才可以吃到 Git 的語法

--

--

itsems
itsems_frontend

Stay Close to Anything that Makes You Glad You are Alive.