第 3 章 Github.com
主畫面有好幾個tab:Code, Issue, Pull requests, Projects, Wiki, Insights 及 Settings
3.1 Code
所有備份(含歷史事件簿)儲存的地方。
- 點
可在線上進行歷史改變revert的動作。
3.2 Fork
由於HelloGithub為公開repo,任何Github用戶皆可拿回去使用,這個拿個備份回去使用的動作叫Fork。
- 點
即可「取得備份」。
HelloGithub狀態:
- tpemartin: 擁有者
使用者PoMingChen取得tpemartin/HelloGithub repo備份。
- PoMingChen: Fork使用者
在Github雲端平台fork的repo會放在自己的帳戶內。
自己擁有的repo
複製別人的repo
3.2.1 Clone(複製回主機)
雲端的repo要在Desktop進行clone才會抓回到你主機供你修改使用。

Clone 1

Clone 2
3.3 Collaboration
善用Fork可以促進團隊合作效率。用法是組長為repo擁有者,組員各自fork一份repo回自己雲端與主機。
以下說明皆以tpemartin為組長,PoMingChen為fork組員。
3.3.1 Edit different files
組長tpemartin(上方)與組員PM(下方)各自編輯不同文件後commit且push上傳。

編輯不同檔案
3.3.2 組員送出Pull request
PM 想回報tpemartin更新進度,並請tpemartin收錄他的更新變動:

在Desktop進行Pull request: 選Create Pull Request

GitHub視窗跳出Open a pull request
3.3.3 組長Merge pull request
tpemartin在Github.com收到pull request通知。依以下步驟處理:

步驟1

步驟2

步驟3

步驟4
3.3.4 更新突衝
有時工作沒協調好,組長與組員同時在編輯一份檔案,如下圖。
若組長與組員皆commit且push了這個更新,而組員送出pull request,此時組員會看到以下有警告訊息的pull request。



組長tpemartin在Github.com收到pull request,必需要解決衝突。









3.4 組員更新Forked repo
組長的repo會因為處理過不同組員的pull request而和組員的repo內容不同,由於組長的repo應該是最新最完整的,組長在整合進度到一段落,應該通知組員更新自己的forked repo。
以下是組員更新forked repo的步驟:

步驟0:點選New pull request

步驟1:檢視差異

步驟2:base fork放組員的forked repo

步驟3:點選compare across forks

步驟4:Head fork放組長的repo

步驟5:點Create pull request

步驟6: 點Merge pull request
- 以上步驟只是雲端上的更新,記得用Desktop更新自己電腦的。