Github上fork項目後與原項目保持同步

**步驟**

假設來源爲 `https://github.com/_original/_project.git`
fork 項目爲  `https://github.com/_your/_project.git`
 


1. 檢出本身在github上fork別人的分支到目錄下  

        git clone https://github.com/_your/_project.git

2. 進到 _project 目錄下,而後增長遠程分支(fork的分支),名爲 update_stream(名字任意)到本地

        git remote add update_stream https://github.com/_original/_project.git

3. 運行命令:`git remote -v`, 會發現多出來了一個update_stream的遠程分支

        git remote -v

4. 而後把遠程原始分支 update_stream 的代碼拉到本地  

        git fetch update_stream
 
5. 合併對方遠程原始分支 update_stream 的代碼

        git merge update_stream/master

6. 最後把最新的代碼推送到你的github上

    git push origin master

7. 若是須要給update_stream發送Pull Request

    打開 `https://github.com/_your/_project.git`  
    點擊Pull Request -> 點擊New Pull Request -> 輸入Title和功能說明 -> 點擊Send pull request

git

相關文章
相關標籤/搜索