-
Notifications
You must be signed in to change notification settings - Fork 343
【欢迎共建】如何提交PR&合并PR
Yang Pei edited this page Jul 15, 2021
·
1 revision
假设要提交pr的开源仓库是A,则:
- fork A 到我的github,形成B仓库
- git clone B.git
- git remote add upstream A.git 添加源,git remote -v可以查看到同时与A、B建立了连接
- git checkout -b xxx 建立本地分支
- 修改代码,git add git commit git push
- 在B仓库发起pull request,选择分支,对比变更
- 确认好变更内容后,点击 Create pull request,完成
- 将Pull Request发出者的派生版本库添加为一个新的源。例如收到来自gotgithub用户的Pull Request,不妨以gotgithub为名添加新的源。
git remote add gotgithub https://github.com/gotgithub/gotgit.git
- 此时版本库中有两个源,一个克隆时自动建立的origin,另外一个就是新增加的gotgithub。
$ git remote -v
gotgithub https://github.com/gotgithub/gotgit.git (fetch)
gotgithub https://github.com/gotgithub/gotgit.git (push)
origin [email protected]:gotgit/gotgit.git (fetch)
origin [email protected]:gotgit/gotgit.git (push)
- 获取远程版本库gotgithub的分支和提交。
$ git fetch gotgithub
From https://github.com/gotgithub/gotgit
* [new branch] gh-pages -> gotgithub/gh-pages
* [new branch] master -> gotgithub/master
- 现在除了本地分支master外,还有若干远程分支,如下:
$ git branch -a
* master
remotes/gotgithub/gh-pages
remotes/gotgithub/master
remotes/origin/HEAD -> origin/master
remotes/origin/gh-pages
remotes/origin/master
- 将他人pr的分支remotes/gotgithub/master(可简写为gotgithub/master,具体分支也可以在github pull request中看到)合并到当前分支中。
$ git merge gotgithub/master
Updating 00c6c4b..7ecdfe7
Fast-forward
errata.mkd | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
- 查看别人添加了怎样的功能和代码(在github pull request中可以看到),启动项目检测功能是否正常、代码是否合理
- 将合并推送到GitHub版本库中
$ git push