Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【20151008】【GITHUB】pull request #29

Closed
zhongxia245 opened this issue Oct 8, 2016 · 0 comments
Closed

【20151008】【GITHUB】pull request #29

zhongxia245 opened this issue Oct 8, 2016 · 0 comments

Comments

@zhongxia245
Copy link
Owner

zhongxia245 commented Oct 8, 2016

总结

pull request 是 开源协作是一个必须品, 是非常重要的。 要为开源库做贡献,就要需要使用该功能。 下面是从知乎上找到的一些资料,方便大家理解 pull request.

作者:beepony
链接:https://www.zhihu.com/question/21682976/answer/79489643
来源:知乎
著作权归作者所有,转载请联系作者获得授权。

例子

我尝试用类比的方法来解释一下 pull reqeust。想想我们中学考试,老师改卷的场景吧。

  1. 你做的试卷就像仓库,你的试卷肯定会有很多错误,就相当于程序里的 bug。
  2. 老师把你的试卷拿过来,相当于先 fork。
  3. 在你的卷子上做一些修改批注,相当于 git commit。
  4. 最后把改好的试卷给你,相当于发 pull request,
  5. 你拿到试卷重新改正错误,相当于 merge。

流程

  1. 当你想更正别人仓库里的错误时,要走一个流程:
  2. 先 fork 别人的仓库,相当于拷贝一份,相信我,不会有人直接让你改修原仓库的
  3. clone 到本地分支,做一些 bug fix
  4. 发起 pull request 给原仓库,让他看到你修改的 bug
  5. 原仓库 review 这个 bug,如果是正确的话,就会 merge 到他自己的项目中
  6. 至此,整个 pull request 的过程就结束了。

具体操作例子

理解了 pull request 的含义和流程,具体操作也就简单了。以 Github 排名最高的 https://github.com/twbs/bootstrap 为例说明。

  1. 先点击 fork 仓库,项目现在就在你的账号下了
  2. 在你自己的机器上 git clone 这个仓库,切换分支(也可以在 master 下),做一些修改。
~  git clone https://github.com/beepony/bootstrap.git
~  cd bootstrap
~  git checkout -b test-pr
~  git add . && git commit -m "test-pr"
~  git push origin test-pr
  1. 完成修改之后,回到 test-pr 分支,点击旁边绿色的 Compare & pull request 按钮
  2. 添加一些注释信息,确认提交
  3. 仓库作者看到,你提的确实是对的,就会 merge,合并到他的项目中

以上就是 pull reqesut 的整个流程,希望对你有帮助~

参考文档:

  1. Fork A Repo - User Documentation
  2. Using pull requests
  3. Creating a pull request
@zhongxia245 zhongxia245 changed the title 【20150925】pull request 【20151008】【GITHUB】pull request Oct 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant