Intro
用 Eclipse 與 GitHub 連結Github的每個repository就是一個專案
雖有人提過可以用branch來做multi-projects
但還是別扭曲本意
Context
> 在 GitHub 建立好 Repository
.git資料夾(包含header檔, 這些暫時稱為 git header) 會記錄 Project 的相關檔案
所以你不能在 local 建立 git header 後, 把它上傳到 GitHub
GitHub 在你建立 Repository 時, 就會同時把 git header 準備好
因此我們只能先從 GitHub 上面拿下來
> Clone Repository URL
在每個 Repository 裡, 右邊 menu 的最下面有個 clone 的按鈕
> 在 Eclipse > File > Import > Projects from Git
> [Select Repository Source]
> [Clone URI]
> Next
> [Source Git Repository]
> [URI]: 剛才複製的
> [User]&[Password]: 你在GitHub的帳號&密碼
> Next
> [Branch Selection]: 第一次 預設為 master
> Next
> [Local Destination]: 看你要把 Project 放在哪裡開發
local 的 git header 會被儲存在這裡
我的習慣是放在 workspace/project name
> Next
> [Select a wizard to use for importing projects]
若你是剛建立的 Repository 可以考慮用 [Use the New Project wizard] 建立一個新的 Project
若是要用已建立好的 就用 Import existing projects
> Next
> 假設我們選擇 [C++ Project]
> [Project name]: 你的project name
要讓你的 git header 跟你的 project 儲存在同一個位置
也就是前面設定 git header [Local Destination]
> Finish
完成, 接著簡單說明一下使用方式
> 在 Project 按右鍵 > Team
>Commit
這個是 commit 到 local 端, github 不會被改變
>Push to Upstream
這才會更新到 github
>Fetch from Upstream
相對的, 將 github 的檔案 fetch 下來
沒有留言:
張貼留言