介紹如何在 Visual Studio Community 2015 的 IDE 中, 連接上 GitHub. 現在 Visual Studio Community 2015 是免費的.
1. 首先在 GitHub 上建立一個 repository(Demo)
![image image](https://lh3.googleusercontent.com/-NKq1-kWIlAE/V_Su_TIJfYI/AAAAAAAAJCc/ehJtLX948W4/image_thumb%25255B50%25255D.png?imgmax=800)
HTTPS 後面的, 就是可以存取到這個 repository 的網路位置.
![image image](https://lh3.googleusercontent.com/-23j306edEN4/V_SvDf0LmMI/AAAAAAAAJCk/7oo6JtpkbKQ/image_thumb%25255B52%25255D.png?imgmax=800)
2. 在本機端建立一個 github 的目錄.
![image image](https://lh3.googleusercontent.com/-DnzrosDRzNU/V_SvHO00FpI/AAAAAAAAJCs/VMXr88vWZvc/image_thumb%25255B53%25255D.png?imgmax=800)
3. 設定 Visual Studio 的 GitHub
在 Team Explorer 的分頁, 按下 Home 按紐, 以切換到 Home 分頁
![image image](https://lh3.googleusercontent.com/-dWe7v4LOqUU/V_SvLCHbevI/AAAAAAAAJC4/XQu-Wl4y94c/image_thumb%25255B55%25255D.png?imgmax=800)
選擇 Settings. 再選擇 Settings 下的 Global Settings. 填入 User name, email address, Default Repository Location 填入先前給定的路徑. 最後按下 Update 更新.
![image image](https://lh3.googleusercontent.com/-t_cVwDO97to/V_SvOv6hz3I/AAAAAAAAJDA/eo0-YEyAJ_w/image_thumb%25255B56%25255D.png?imgmax=800)
4. 在 Visual Studio 建立一個新的專案, Location 指向 先前給定的路徑.
![image image](https://lh3.googleusercontent.com/-wFO05ol7w_M/V_SvSBBNw7I/AAAAAAAAJDI/N8Z9dZSlMUQ/image_thumb%25255B58%25255D.png?imgmax=800)
完成後儲存專案.
![image image](https://lh3.googleusercontent.com/-xgkm8CU6uHk/V_SvYhO2r-I/AAAAAAAAJDQ/pBpD9A167lc/image_thumb%25255B59%25255D.png?imgmax=800)
專案檔案已生成在路徑中.
![image image](https://lh3.googleusercontent.com/-cIX_kCWWSfU/V_Svb1XAIGI/AAAAAAAAJDY/XRkJCF4NC3s/image_thumb%25255B60%25255D.png?imgmax=800)
5. 將專案加入 Source Control
在 Solution Explorer 的分頁中. 在 Solution 名稱上按右鍵, 在彈出功能選單中, 選取 Add Solution to Source Control.
然後切換到 Team Explorer 畫面. 可以看到專案已被加入 local repository.
![image image](https://lh3.googleusercontent.com/-vBTqZjfEBaI/V_SveRzmK5I/AAAAAAAAJDg/AWkEQcUFj3I/image_thumb%25255B63%25255D.png?imgmax=800)
把 Enter a comment message 改掉 (譬如 Initial Version), Commit All 的顏色才會變成可以按下的狀態.
![image image](https://lh3.googleusercontent.com/-SIRxbxAJkws/V_SvhEs5qTI/AAAAAAAAJDo/mcN_0tDMgl8/image_thumb%25255B64%25255D.png?imgmax=800)
然後就 Commit All. 把變更加入 local repository.
6. 同步到 GitHub
在 Changes 分頁, 按下 Sync (藍色有底線的字 ). 切換到 Publish 頁面.
![image image](https://lh3.googleusercontent.com/-9axKfiINjuQ/V_Svj-RhFUI/AAAAAAAAJDw/g6nc1HEOgqw/image_thumb%25255B66%25255D.png?imgmax=800)
這個頁面有 3 個項目:
1. Publish to Visual Studio Team Services ( 這是 Microsoft 的 Team Server)
2. Publish to GitHub (這是我另外安裝的 Git extension for Visual Studio, 也可以用, 但不是這邊的重點)
3. Publish to Remote Repository (這是以下要說明的方法)
![image image](https://lh3.googleusercontent.com/-iJ7pBRSWENQ/V_SvnF1-jSI/AAAAAAAAJD4/2H2Xfs1D2l4/image_thumb%25255B68%25255D.png?imgmax=800)
展開 Publish to Remote Repository, 在 “Enter the URL of an empty Git repo” , 代換成 GitHub 的 URL, 例如
“https://github.com/lxnick/Demo.git” 然後按下 Publish.
![image image](https://lh3.googleusercontent.com/-1PkVTtBO-Pw/V_SvpzdoidI/AAAAAAAAJEA/8H7mgFCjcgw/image_thumb%25255B69%25255D.png?imgmax=800)
7. 完成. 回到 GitHub 的網頁. 檔案資料已經上傳.
![image image](https://lh3.googleusercontent.com/-LTB5IE114kM/V_Svs8UShdI/AAAAAAAAJEM/RTIbVjqvJgM/image_thumb%25255B71%25255D.png?imgmax=800)