Files
KnowStreaming/docs/contributer_guide/贡献流程.md
2022-10-10 16:55:33 +08:00

122 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 贡献流程
[贡献源码细则](../CONTRIBUTING.md)
#### 1. fork didi/KnowStreaming项目到您的github库
找到你要Fork的项目,例如 [KnowStreaming](https://github.com/didi/KnowStreaming) ,点击Fork按钮。
![在这里插入图片描述](https://img-blog.csdnimg.cn/ac7bfef9ccde49d587c30e702a615ef5.png)
#### 2. 克隆或下载您fork的Nacos代码仓库到您本地
```sh
git clone { your fork knowstreaming repo address }
cd KnowStreaming
```
#### 3. 添加 didi/KnowStreaming仓库为upstream仓库
```sh
### 添加源仓库
git remote add upstream https://github.com/didi/KnowStreaming
### 查看是否添加成功
git remote -v
origin ${your fork KnowStreaming repo address} (fetch)
origin ${your fork KnowStreaming repo address} (push)
upstream https://github.com/didi/KnowStreaming(fetch)
upstream https://github.com/didi/KnowStreaming (push)
### 获取源仓库的基本信息
git fetch origin
git fetch upstream
```
上面是将didi/KnowStreaming添加为远程仓库, 当前就会有2个远程仓库
1. origin 你Fork出来的分叉仓库
2. upstream 源仓库
git fetch 获取远程仓库的基本信息, 比如 **源仓库**的所有分支就获取到了
#### 4. 同步源仓库开发分支到本地分叉仓库中
一般开源项目都会有一个给贡献者提交代码的分支,例如 KnowStreaming的分支是 `dev`
首先我们要将 **源仓库**的开发分支(`dev`) 拉取到本地仓库中
```sh
git checkout -b dev upstream/dev
```
**或者IDEA的形式创建**
![在这里插入图片描述](https://img-blog.csdnimg.cn/c95f2601a9af41889a5fc20b2a9724a5.png)
#### 5. 在本地新建的开发分支上进行修改
首先请保证您阅读并正确设置KnowStreaming code style, 相关内容请阅读[KnowStreaming 代码规约 ]()。
修改时请保证该分支上的修改仅和issue相关并尽量细化做到
<font color=red><b>一个分支只修改一件事一个PR只修改一件事</b></font>
同时,您的提交记录请尽量描述清楚,主要以谓 + 宾进行描述Fix xxx problem/bug。少量简单的提交可以使用For xxx来描述For codestyle。 如果该提交和某个ISSUE相关可以添加ISSUE号作为前缀For #10000, Fix xxx problem/bug。
#### 6. Rebase 基础分支和开发分支
您修改的时候可能别人的修改已经提交并被合并此时可能会有冲突这里请使用rebase命令进行合并解决主要有2个好处
1. 您的提交记录将会非常优雅不会出现Merge xxxx branch 等字样
2. rebase后您分支的提交日志也是一条单链基本不会出现各种分支交错的情况回查时更轻松
```sh
git fetch upstream
git rebase -i upstream/dev
```
**或者在IDEA的操作如下**
![在这里插入图片描述](https://img-blog.csdnimg.cn/d75addcfa9564d3d9e1d226a2f7f4d64.png)
选择 源仓库的开发分支
![在这里插入图片描述](https://img-blog.csdnimg.cn/4e85714df13b44bcb10f1e655450cb72.png)
推荐使用IDEA的方式, 有冲突的时候更容易解决冲突问题。
#### 7. 将您开发完成rebase后的分支上传到您fork的仓库
```sh
git push origin dev
```
#### 8. 按照PR模板中的清单创建Pull Request
![在这里插入图片描述](https://img-blog.csdnimg.cn/1dab060aed314666970e3910e05f2205.png)
选择自己的分支合并到模板分支。
#### 9. 等待合并代码
提交了PR之后需要等待PMC、Commiter 来Review代码如果有问题需要配合修改重新提交。
如果没有问题会直接合并到开发分支`dev`中。
注: 如果长时间没有review, 则可以多催促社区来Review代码