contribute_to_paddle_cn.html 28.4 KB
Newer Older
1 2


3 4


5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>如何贡献代码 &mdash; PaddlePaddle  文档</title>
  

  
  

  

  
  
    

  

  
  
29
    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
30 31 32
  

  
33

34 35
  
        <link rel="index" title="索引"
36 37 38 39 40 41
              href="../genindex.html"/>
        <link rel="search" title="搜索" href="../search.html"/>
    <link rel="top" title="PaddlePaddle  文档" href="../index.html"/>
        <link rel="up" title="开发标准" href="index_cn.html"/>
        <link rel="next" title="如何贡献文档" href="write_docs_cn.html"/>
        <link rel="prev" title="开发标准" href="index_cn.html"/> 
42 43 44 45 46 47 48 49 50 51
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

52 53

  
54
  <script src="../_static/js/modernizr.min.js"></script>
55 56 57 58 59

</head>

<body class="wy-body-for-nav" role="document">

60 61 62 63 64 65 66 67 68 69 70 71 72
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index_cn.html" class="icon icon-home"> PaddlePaddle
          

          
73 74
          </a>

75 76 77 78 79 80
          
            
            
          

          
81
<div role="search">
82
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
83 84 85 86
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
87
</div>
88 89

          
90 91 92 93
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
94 95 96 97 98 99
<nav class="doc-menu-vertical" role="navigation">

<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../getstarted/quickstart_cn.html">快速开始</a></li>
<li class="toctree-l2"><a class="reference internal" href="../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
100 101
</ul>
</li>
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
<li class="toctree-l1"><a class="reference internal" href="../build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../build_and_install/pip_install_cn.html">使用pip安装</a></li>
<li class="toctree-l2"><a class="reference internal" href="../build_and_install/docker_install_cn.html">使用Docker安装运行</a></li>
<li class="toctree-l2"><a class="reference internal" href="../build_and_install/build_from_source_cn.html">从源码编译</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../howto/index_cn.html">进阶使用</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../howto/cmd_parameter/index_cn.html">命令行参数设置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../howto/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../howto/cluster/index_cn.html">分布式训练</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../howto/cluster/preparations_cn.html">环境准备</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/cluster/cmd_argument_cn.html">启动参数说明</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/cluster/multi_cluster/index_cn.html">在不同集群中运行</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../howto/cluster/multi_cluster/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l4"><a class="reference internal" href="../howto/cluster/multi_cluster/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l4"><a class="reference internal" href="../howto/cluster/multi_cluster/openmpi_cn.html">在OpenMPI集群中启动训练</a></li>
<li class="toctree-l4"><a class="reference internal" href="../howto/cluster/multi_cluster/fabric_cn.html">使用fabric启动集群训练</a></li>
<li class="toctree-l4"><a class="reference internal" href="../howto/cluster/multi_cluster/k8s_aws_cn.html">Kubernetes on AWS</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../howto/capi/index_cn.html">C-API预测库</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../howto/capi/compile_paddle_lib_cn.html">安装与编译C-API预测库</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/capi/organization_of_the_inputs_cn.html">输入/输出数据组织</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/capi/workflow_of_capi_cn.html">C-API使用流程</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../howto/rnn/index_cn.html">RNN模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../howto/rnn/rnn_config_cn.html">RNN配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../howto/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../howto/optimization/gpu_profiling_cn.html">GPU性能调优</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="reference internal" href="index_cn.html">开发标准</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">如何贡献代码</a></li>
146
<li class="toctree-l2"><a class="reference internal" href="write_docs_cn.html">如何贡献文档</a></li>
147
<li class="toctree-l2"><a class="reference internal" href="new_layer_cn.html">如何实现新的网络层</a></li>
148 149
</ul>
</li>
150 151 152 153 154 155 156 157
<li class="toctree-l1"><a class="reference internal" href="../faq/index_cn.html">FAQ</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../faq/build_and_install/index_cn.html">编译安装与单元测试</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/model/index_cn.html">模型配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/parameter/index_cn.html">参数设置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/local/index_cn.html">本地训练与预测</a></li>
<li class="toctree-l2"><a class="reference internal" href="../faq/cluster/index_cn.html">集群训练与预测</a></li>
</ul>
</li>
158 159
</ul>

160 161
</nav>

162 163
        </div>
      </div>
164 165
    </nav>

166
    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
167

168 169 170 171 172
      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../index_cn.html">PaddlePaddle</a>
      </nav>
173 174


175 176 177 178
      
      <div class="wy-nav-content">
        <div class="rst-content">
          
179

180
 
181 182 183 184 185



<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
186
    <li><a href="../index_cn.html">Docs</a> &raquo;</li>
187
      
188
          <li><a href="index_cn.html">开发标准</a> &raquo;</li>
189
      
190
    <li>如何贡献代码</li>
191 192 193 194 195 196 197
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../_sources/dev/contribute_to_paddle_cn.md.txt" rel="nofollow"> View page source</a>
          
        
      </li>
198
  </ul>
199
  <hr/>
200 201 202 203 204 205 206 207 208 209
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="">
<span id="id1"></span><h1>如何贡献代码<a class="headerlink" href="#" title="永久链接至标题"></a></h1>
<p>我们真诚地感谢您的贡献,欢迎通过 GitHub 的 fork 和 pull request 流程来提交代码。</p>
<div class="section" id="">
<span id="id2"></span><h2>代码要求<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<ul class="simple">
210 211
<li>代码注释请遵守 <a class="reference external" href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a> 的样式。</li>
<li>确保编译器选项 <code class="docutils literal"><span class="pre">WITH_STYLE_CHECK</span></code> 已打开,并且编译能通过代码样式检查。</li>
212 213
<li>所有代码必须具有单元测试。</li>
<li>通过所有单元测试。</li>
214
<li>请遵守<a class="reference external" href="#提交代码的一些约定">提交代码的一些约定</a></li>
215 216 217 218 219
</ul>
<p>以下教程将指导您提交代码。</p>
</div>
<div class="section" id="fork">
<span id="fork"></span><h2><a class="reference external" href="https://help.github.com/articles/fork-a-repo/">Fork</a><a class="headerlink" href="#fork" title="永久链接至标题"></a></h2>
220
<p>跳转到<a class="reference external" href="https://github.com/PaddlePaddle/Paddle">PaddlePaddle</a> GitHub首页,然后单击 <code class="docutils literal"><span class="pre">Fork</span></code> 按钮,生成自己目录下的仓库,比如 <a class="reference external" href="https://github.com/USERNAME/Paddle">https://github.com/USERNAME/Paddle</a></p>
221 222 223
</div>
<div class="section" id="clone">
<span id="clone"></span><h2>克隆(Clone)<a class="headerlink" href="#clone" title="永久链接至标题"></a></h2>
224 225 226
<p>将远程仓库 clone 到本地:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git clone https://github.com/USERNAME/Paddle
<span class="nb">cd</span> Paddle
227 228 229
</pre></div>
</div>
</div>
230 231 232 233 234 235
<div class="section" id="">
<span id="id3"></span><h2>创建本地分支<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>Paddle 目前使用<a class="reference external" href="http://nvie.com/posts/a-successful-git-branching-model/">Git流分支模型</a>进行开发,测试,发行和维护,具体请参考 <a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/releasing_process.md#paddle-分支规范">Paddle 分支规范</a></p>
<p>所有的 feature 和 bug fix 的开发工作都应该在一个新的分支上完成,一般从 <code class="docutils literal"><span class="pre">develop</span></code> 分支上创建新分支。</p>
<p>使用 <code class="docutils literal"><span class="pre">git</span> <span class="pre">checkout</span> <span class="pre">-b</span></code> 创建并切换到新分支。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git checkout -b my-cool-stuff
236 237
</pre></div>
</div>
238
<p>值得注意的是,在 checkout 之前,需要保持当前分支目录 clean,否则会把 untracked 的文件也带到新分支上,这可以通过 <code class="docutils literal"><span class="pre">git</span> <span class="pre">status</span></code> 查看。</p>
239 240 241
</div>
<div class="section" id="pre-commit">
<span id="pre-commit"></span><h2>使用 <code class="docutils literal"><span class="pre">pre-commit</span></code> 钩子<a class="headerlink" href="#pre-commit" title="永久链接至标题"></a></h2>
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
<p>Paddle 开发人员使用 <a class="reference external" href="http://pre-commit.com/">pre-commit</a> 工具来管理 Git 预提交钩子。 它可以帮助我们格式化源代码(C++,Python),在提交(commit)前自动检查一些基本事宜(如每个文件只有一个 EOL,Git 中不要添加大文件等)。</p>
<p><code class="docutils literal"><span class="pre">pre-commit</span></code>测试是 Travis-CI 中单元测试的一部分,不满足钩子的 PR 不能被提交到 Paddle,首先安装并在当前目录运行它:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  pip install pre-commit
➜  pre-commit install
</pre></div>
</div>
<p>Paddle 使用 <code class="docutils literal"><span class="pre">clang-format</span></code> 来调整 C/C++ 源代码格式,请确保 <code class="docutils literal"><span class="pre">clang-format</span></code> 版本在 3.8 以上。</p>
</div>
<div class="section" id="">
<span id="id4"></span><h2>开始开发<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>在本例中,我删除了 README.md 中的一行,并创建了一个新文件。</p>
<p>通过 <code class="docutils literal"><span class="pre">git</span> <span class="pre">status</span></code> 查看当前状态,这会提示当前目录的一些变化,同时也可以通过 <code class="docutils literal"><span class="pre">git</span> <span class="pre">diff</span></code> 查看文件具体被修改的内容。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git status
On branch <span class="nb">test</span>
Changes not staged <span class="k">for</span> commit:
  <span class="o">(</span>use <span class="s2">&quot;git add &lt;file&gt;...&quot;</span> to update what will be committed<span class="o">)</span>
  <span class="o">(</span>use <span class="s2">&quot;git checkout -- &lt;file&gt;...&quot;</span> to discard changes in working directory<span class="o">)</span>

    modified:   README.md

Untracked files:
  <span class="o">(</span>use <span class="s2">&quot;git add &lt;file&gt;...&quot;</span> to include in what will be committed<span class="o">)</span>

    <span class="nb">test</span>

no changes added to commit <span class="o">(</span>use <span class="s2">&quot;git add&quot;</span> and/or <span class="s2">&quot;git commit -a&quot;</span><span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="">
<span id="id5"></span><h2>构建和测试<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
273
<p>编译 PaddlePaddle 的源码以及生成文档需要多种开发工具。为了方便大家,我们的标准开发流程是把这些工具都装进一个Docker image,称为<em>开发镜像</em>,通常名字是 <code class="docutils literal"><span class="pre">paddle:latest-dev</span></code> 或者 <code class="docutils literal"><span class="pre">paddle:[version</span> <span class="pre">tag]-dev</span></code><code class="docutils literal"><span class="pre">paddle:0.11.0-dev</span></code>。然后所有用 <code class="docutils literal"><span class="pre">cmake</span> <span class="pre">&amp;&amp;</span> <span class="pre">make</span></code> 的地方(比如IDE配置里)都用 <code class="docutils literal"><span class="pre">docker</span> <span class="pre">run</span> <span class="pre">paddle:latest-dev</span></code>来代替。</p>
274
<p>如要build这个开发镜像,在源码目录树的根目录中运行:</p>
275
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  docker build -t paddle:latest-dev .
276 277
</pre></div>
</div>
278
<p>随后可以用这个开发镜像开始build PaddlePaddle的源码。比如如果要build一个不依赖GPU,但是支持AVX指令集,并且包括unit tests的PaddlePaddle,可以:</p>
279
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  docker run -v <span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span>:/paddle -e <span class="s2">&quot;WITH_GPU=OFF&quot;</span> -e <span class="s2">&quot;WITH_AVX=ON&quot;</span> -e <span class="s2">&quot;WITH_TESTING=ON&quot;</span> paddle:latest-dev
280 281 282 283 284 285 286
</pre></div>
</div>
<p>这个过程除了编译PaddlePaddle为 <code class="docutils literal"><span class="pre">./build/libpaddle.so</span></code>,并且输出一个 <code class="docutils literal"><span class="pre">./build/paddle.deb</span></code>文件之外,还会输出一个 <code class="docutils literal"><span class="pre">build/Dockerfile</span></code>。我们只需要运行下面命令把编译好的PaddlePaddle打包成一个<em>生产镜像</em><code class="docutils literal"><span class="pre">paddle:prod</span></code>):</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  docker build -t paddle:prod -f build/Dockerfile .
</pre></div>
</div>
<p>如果要运行所有的单元测试,可以用如下命令:</p>
287
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  docker run -it -v <span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span>:/paddle paddle:latest-dev bash -c <span class="s2">&quot;cd /paddle/build &amp;&amp; ctest&quot;</span>
288 289 290
</pre></div>
</div>
<p>关于构建和测试的更多信息,请参见<a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst">这篇文档</a></p>
291 292
</div>
<div class="section" id="commit">
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
<span id="commit"></span><h2>提交(commit)<a class="headerlink" href="#commit" title="永久链接至标题"></a></h2>
<p>接下来我们取消对 README.md 文件的改变,然后提交新添加的 test 文件。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git checkout -- README.md
➜  git status
On branch <span class="nb">test</span>
Untracked files:
  <span class="o">(</span>use <span class="s2">&quot;git add &lt;file&gt;...&quot;</span> to include in what will be committed<span class="o">)</span>

    <span class="nb">test</span>

nothing added to commit but untracked files present <span class="o">(</span>use <span class="s2">&quot;git add&quot;</span> to track<span class="o">)</span>
➜  git add <span class="nb">test</span>
</pre></div>
</div>
<p>Git 每次提交代码,都需要写提交说明,这可以让其他人知道这次提交做了哪些改变,这可以通过<code class="docutils literal"><span class="pre">git</span> <span class="pre">commit</span></code> 完成。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git commit
CRLF end-lines remover...............................<span class="o">(</span>no files to check<span class="o">)</span>Skipped
yapf.................................................<span class="o">(</span>no files to check<span class="o">)</span>Skipped
Check <span class="k">for</span> added large files..............................................Passed
Check <span class="k">for</span> merge conflicts................................................Passed
Check <span class="k">for</span> broken symlinks................................................Passed
Detect Private Key...................................<span class="o">(</span>no files to check<span class="o">)</span>Skipped
Fix End of Files.....................................<span class="o">(</span>no files to check<span class="o">)</span>Skipped
clang-formater.......................................<span class="o">(</span>no files to check<span class="o">)</span>Skipped
<span class="o">[</span>my-cool-stuff c703c041<span class="o">]</span> add <span class="nb">test</span> file
 <span class="m">1</span> file changed, <span class="m">0</span> insertions<span class="o">(</span>+<span class="o">)</span>, <span class="m">0</span> deletions<span class="o">(</span>-<span class="o">)</span>
 create mode <span class="m">100644</span> <span class="m">233</span>
320 321 322
</pre></div>
</div>
</div>
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
<div class="section" id="">
<span id="id6"></span><h2>保持本地仓库最新<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>在准备发起 Pull Request 之前,需要同步原仓库(<a class="reference external" href="https://github.com/PaddlePaddle/Paddle">https://github.com/PaddlePaddle/Paddle</a>)最新的代码。</p>
<p>首先通过 <code class="docutils literal"><span class="pre">git</span> <span class="pre">remote</span></code> 查看当前远程仓库的名字。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git remote
origin
➜  git remote -v
origin  https://github.com/USERNAME/Paddle <span class="o">(</span>fetch<span class="o">)</span>
origin  https://github.com/USERNAME/Paddle <span class="o">(</span>push<span class="o">)</span>
</pre></div>
</div>
<p>这里 origin 是我们 clone 的远程仓库的名字,也就是自己用户名下的 Paddle,接下来我们创建一个原始 Paddle 仓库的远程主机,命名为 upstream。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git remote add upstream https://github.com/PaddlePaddle/Paddle
➜  git remote
origin
upstream
339 340
</pre></div>
</div>
341 342 343
<p>获取 upstream 的最新代码并更新当前分支。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git fetch upstream
➜  git pull upstream develop
344 345 346
</pre></div>
</div>
</div>
347 348 349 350 351
<div class="section" id="push">
<span id="push"></span><h2>Push 到远程仓库<a class="headerlink" href="#push" title="永久链接至标题"></a></h2>
<p>将本地的修改推送到 GitHub 上,也就是 https://github.com/USERNAME/Paddle。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># 推送到远程仓库 origin 的 my-cool-stuff 分支上</span>
➜  git push origin my-cool-stuff
352 353 354
</pre></div>
</div>
</div>
355 356 357 358 359 360 361
<div class="section" id="issue-pull-request">
<span id="issue-pull-request"></span><h2>建立 Issue 并完成 Pull Request<a class="headerlink" href="#issue-pull-request" title="永久链接至标题"></a></h2>
<p>建立一个 Issue 描述问题,并记录它的编号。</p>
<p>切换到所建分支,然后点击 <code class="docutils literal"><span class="pre">New</span> <span class="pre">pull</span> <span class="pre">request</span></code></p>
<p><img width="295" alt="screen shot 2017-04-26 at 9 09 28 pm" src="https://cloud.githubusercontent.com/assets/11692045/25436054/a6d98c66-2ac4-11e7-9cb1-18dd13150230.png"></p>
<p>选择目标分支:</p>
<p><img width="750" alt="screen shot 2017-04-26 at 9 11 52 pm" src="https://cloud.githubusercontent.com/assets/11692045/25436139/f83b1e6c-2ac4-11e7-8c0e-add499023c46.png"></p>
362
<p>在 PR 的描述说明中,填写 <code class="docutils literal"><span class="pre">resolve</span> <span class="pre">#Issue编号</span></code> 可以在这个 PR 被 merge 后,自动关闭对应的 Issue,具体请见 <a class="reference external" href="https://help.github.com/articles/closing-issues-via-commit-messages/">https://help.github.com/articles/closing-issues-via-commit-messages/</a></p>
363
<p>接下来等待 review,如果有需要修改的地方,参照上述步骤更新 origin 中的对应分支即可。</p>
364
</div>
365 366 367 368 369 370
<div class="section" id="">
<span id="id7"></span><h2>删除远程分支<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>在 PR 被 merge 进主仓库后,我们可以在 PR 的页面删除远程仓库的分支。</p>
<p><img width="775" alt="screen shot 2017-04-26 at 9 18 24 pm" src="https://cloud.githubusercontent.com/assets/11692045/25436457/e4cdd472-2ac5-11e7-9272-badc76c4a23e.png"></p>
<p>也可以使用 <code class="docutils literal"><span class="pre">git</span> <span class="pre">push</span> <span class="pre">origin</span> <span class="pre">:分支名</span></code> 删除远程分支,如:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>➜  git push origin :my-cool-stuff
371 372 373
</pre></div>
</div>
</div>
374 375 376 377 378 379 380 381
<div class="section" id="">
<span id="id8"></span><h2>删除本地分支<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>最后,删除本地分支。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># 切换到 develop 分支</span>
➜  git checkout develop 

<span class="c1"># 删除 my-cool-stuff 分支</span>
➜  git branch -D my-cool-stuff
382 383
</pre></div>
</div>
384
<p>至此,我们就完成了一次代码贡献的过程。</p>
385
</div>
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
<div class="section" id="">
<span id="id9"></span><h2>提交代码的一些约定<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>为了使评审人在评审代码时更好地专注于代码本身,请您每次提交代码时,遵守以下约定:</p>
<ol class="simple">
<li>请保证Travis-CI 中单元测试能顺利通过。如果没过,说明提交的代码存在问题,评审人一般不做评审。</li>
<li>提交PUll Request前:<ul>
<li>请注意commit的数量:<ul>
<li>原因:如果仅仅修改一个文件但提交了十几个commit,每个commit只做了少量的修改,这会给评审人带来很大困扰。评审人需要逐一查看每个commit才能知道做了哪些修改,且不排除commit之间的修改存在相互覆盖的情况。</li>
<li>建议:每次提交时,保持尽量少的commit,可以通过<code class="docutils literal"><span class="pre">git</span> <span class="pre">commit</span> <span class="pre">--amend</span></code>补充上次的commit。对已经Push到远程仓库的多个commit,可以参考<a class="reference external" href="http://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed">squash commits after push</a></li>
</ul>
</li>
<li>请注意每个commit的名称:应能反映当前commit的内容,不能太随意。</li>
</ul>
</li>
<li>如果解决了某个Issue的问题,请在该PUll Request的<strong>第一个</strong>评论框中加上:<code class="docutils literal"><span class="pre">fix</span> <span class="pre">#issue_number</span></code>,这样当该PUll Request被合并后,会自动关闭对应的Issue。关键词包括:close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved,请选择合适的词汇。详细可参考<a class="reference external" href="https://help.github.com/articles/closing-issues-via-commit-messages">Closing issues via commit messages</a></li>
</ol>
<p>此外,在回复评审人意见时,请您遵守以下约定:</p>
<ol class="simple">
<li>评审人的每个意见都必须回复(这是开源社区的基本礼貌,别人帮了忙,应该说谢谢):<ul>
<li>对评审意见同意且按其修改完的,给个简单的<code class="docutils literal"><span class="pre">Done</span></code>即可;</li>
<li>对评审意见不同意的,请给出您自己的反驳理由。</li>
</ul>
</li>
<li>如果评审意见比较多:<ul>
<li>请给出总体的修改情况。</li>
<li>请采用<a class="reference external" href="https://help.github.com/articles/reviewing-proposed-changes-in-a-pull-request/">start a review</a>进行回复,而非直接回复的方式。原因是每个回复都会发送一封邮件,会造成邮件灾难。</li>
</ul>
</li>
</ol>
</div>
416 417 418 419 420 421 422
</div>


           </div>
          </div>
          <footer>
  
423 424
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
425
        <a href="write_docs_cn.html" class="btn btn-neutral float-right" title="如何贡献文档" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
426 427
      
      
428
        <a href="index_cn.html" class="btn btn-neutral" title="开发标准" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
429 430 431
      
    </div>
  
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2016, PaddlePaddle developers.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
458
            URL_ROOT:'../',
459 460 461
            VERSION:'',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
462
            HAS_SOURCE:  true
463 464
        };
    </script>
465 466 467 468
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>
      <script type="text/javascript" src="../_static/translations.js"></script>
469
      <script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
470

471 472 473 474
  

  
  
475
    <script type="text/javascript" src="../_static/js/theme.js"></script>
476
  
477

478
  
479 480 481 482 483 484 485
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   
486 487

</body>
488
</html>