Github pull request 工作流总结
github 上面有很多非常不錯的開源項目,我們也可以向其貢獻自己的代碼,那么我們如何提交自己的代碼給開源項目呢?這里就要用到 pull request 的提交方式。當然,基于 git 的其他平臺也是類似的用法。
假設源倉庫為:https://github.com/test/pro,你 fork 后得到的倉庫為:https://github.com/your/pro。
流程如下所示:
1. 在開發環境克隆 fork 的倉庫
$ git clone https://github.com/your/pro2. 添加倉庫的 upstream 源
添加 upstream 源,才可以同步源倉庫代碼變動到你 fork 的倉庫。
$ cd pro\r\n$ git remote add upstream https://github.com/test/pro3. 新建 feature 分支
每次修改代碼時,都新建一個分支開發功能或者修復 bug,當然分支的名字自己定。
$ git checkout -b feature4. 提交分支
代碼修改完成后提交 feature 分支:
$ git add ./ $ git commit -m 'some notes' $ git push origin feature4. push feature 分支到 upstream 倉庫
這里 upstream 倉庫為 https://github.com/test/pro。在 github 網站上面創建 pull request,然后等待負責人處理你的 pull request。
5. 刪除 feature 分支
如果你的 pull request 被合并且關閉了,那么你就可以刪除 feature 分支了。
首先切換到 master 分支:
$ git checkout master然后刪除本地 feature 分支:
$ git branch -d feature再刪除遠程 feature 分支:
$ git push origin --delete reature6. 同步代碼
在你 fork 的項目中,更改修改的代碼全在 feature 分支中,而此時 feature 分支已經被刪除了,不過不用擔心,因為修改的代碼已經被源倉庫合并,所以此時需要同步源倉庫的代碼:
$ git pull upstream master $ git push origin master轉載于:https://www.cnblogs.com/hojas/p/9523243.html
總結
以上是生活随笔為你收集整理的Github pull request 工作流总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果没有在发布会上提到 5 个关于 iP
- 下一篇: iPhone 12续航怎么样能看多久视频