如何给开源项目贡献代码
前言
给开源项目贡献代码分两种情况:
- 拥有仓库的写入权限,可以直接 Push
- 没有仓库的写入权限,通过 PR 提交请求
本文将简单说明 PR 的流程,为方便区分,做一下称呼 - 开源仓库:主仓库
Fork 后的仓库:分支仓库
Fork & Pull request
以开源项目awesome-vuepress为例,Fork 开源仓库到自己的账号
分支仓库
克隆分支仓库到本地
$ git clone git@github.com:cnguu/awesome-vuepress.git
一顿操作之后,提交保存
$ git add -A $ git commit -m "feat: something messages" $ git push
主仓库
打开分支仓库首页,New pull request,把刚才的修改提交到主仓库
同步主仓库最新代码
$ git remote add upstream https://github.com/vuepressjs/awesome-vuepress.git $ git fetch upstream $ git merge upstream/master
转载自:https://blog.cnguu.cn/life/ru-he-gei-kai-yuan-xiang-mu-gong-xian-dai-ma.html