Files
oceanbase/docs/docs-cn/15.community-contribution/1.how-to-contribute.md
2022-02-10 14:51:49 +08:00

163 lines
2.8 KiB
Markdown

如何贡献
=========================
OceanBase 数据库是一个开源的项目。欢迎您贡献代码或文档。本文介绍如何为该项目做贡献。
开始之前
-------------------------
欢迎您为 OceanBase 数据库贡献代码或文档。在您开始贡献之前,您需要签署贡献者许可协议(Contributor Licence Agreement,简称 CLA)。详细信息,参考 [什么是 CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement)。点击 [OceaBase CLA](https://cla-assistant.io/oceanbase/oceanbase?pullRequest=108),点击 **Sign in with GitHub to agree** 按钮签署协议。
贡献指南
-------------------------
**注意**
本节介绍如何为 `master` 分支创建 PR。为其他分支创建 PR 的步骤与此按照以下步骤提交 Pull Request(简称 PR):
类似。
**步骤 1:Fork 项目仓库**
1. 访问项目的 [GitHub 地址](https://github.com/oceanbase/oceanbase)。
2. 点击 Fork 按钮创建远程分支。
**步骤2:克隆分支到本地**
1. 定义工作目录。
```bash
# 定义工作目录
working_dir=$HOME/Workspace
```
2. 配置 GitHub 用户名。
```bash
user={GitHub账户名}
```
3. 克隆代码。
```bash
# 克隆代码
mkdir -p $working_dir
cd $working_dir
git clone git@github.com:$user/oceanbase.git
# 或: git clone https://github.com/$user/oceanbase.git
# 添加上游分支
cd $working_dir/oceanbase
git remote add upstream git@github.com:oceanbase/oceanbase.git
# 或: git remote add upstream https://github.com/oceanbase/oceanbase.git
# 为上游分支设置 no_push
git remote set-url --push upstream no_push
# 确认远程分支有效
git remote -v
```
**步骤 3:创建新分支**
1. 更新本地 `master` 分支。
```bash
cd $working_dir/oceanbase
git fetch upstream
git checkout master
git rebase upstream/master
```
2. 基于本地 `master` 分支创建新分支。
```bash
git checkout -b new-branch-name
```
**步骤 4:开发**
在 `new-branch-name` 上开发并保存更改。
**步骤 5:提交更改**
```bash
# 检查本地文件状态
git status
# 添加您希望提交的文件
# 如果您希望提交所有更改,直接使用 `git add .`
git add <file> ...
git commit -m "commit-message: update the xx"
```
**步骤 6:保持开发分支与上游分支同步**
```bash
# 在开发分支执行以下操作
git fetch upstream
git rebase upstream/master
```
**步骤 7:推送更改至远程分支**
```bash
# 在开发分支执行以下操作
git push -u origin new-branch-name
```
**步骤 8:创建 PR**
1. 访问您 Fork 的仓库。
2. 单击 `new-branch-name` 分支旁的 `Compare & pull request` 按钮。