blob: 0e791676dbfaae03951bfc3cd516cbe240a5a1dc [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Git Workflow · Apache SINGA</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="&lt;!--- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --&gt;"/><meta name="docsearch:version" content="2.0.0"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Git Workflow · Apache SINGA"/><meta property="og:type" content="website"/><meta property="og:url" content="https://singa.apache.org/"/><meta property="og:description" content="&lt;!--- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --&gt;"/><meta property="og:image" content="https://singa.apache.org/img/singa_twitter_banner.jpeg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://singa.apache.org/img/singa_twitter_banner.jpeg"/><link rel="shortcut icon" href="/img/favicon.ico"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"/><link rel="alternate" type="application/atom+xml" href="https://singa.apache.org/blog/atom.xml" title="Apache SINGA Blog ATOM Feed"/><link rel="alternate" type="application/rss+xml" href="https://singa.apache.org/blog/feed.xml" title="Apache SINGA Blog RSS Feed"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,700"/><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Baloo+Paaji+2&amp;family=Source+Sans+Pro:wght@200;300&amp;display=swap"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js"></script><script>
document.addEventListener('DOMContentLoaded', function() {
addBackToTop(
{"zIndex":100}
)
});
</script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/singa.png" alt="Apache SINGA"/></a><a href="/versions"><h3>2.0.0</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/2.0.0/installation" target="_self">Docs</a></li><li class=""><a href="/docs/2.0.0/source-repository" target="_self">Community</a></li><li class=""><a href="/blog/" target="_self">News</a></li><li class=""><a href="https://apache-singa.readthedocs.io/en/latest/" target="_self">API</a></li><li class="navSearchWrapper reactNavSearchWrapper"><input type="text" id="search_input_react" placeholder="Search" title="Search"/></li><li class=""><a href="https://github.com/apache/singa" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/apache/singa-doc/blob/master/docs-site/docs/git-workflow.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Git Workflow</h1></header><article><div><span><!--- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<h2><a class="anchor" aria-hidden="true" id="对于开发者"></a><a href="#对于开发者" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>对于开发者</h2>
<ol>
<li><p><a href="https://github.com/apache/singa">SINGA Github repository</a> fork到你自己的Github账户。</p></li>
<li><p>从你自己的git仓库中clone <strong>repo</strong> (short for repository):</p>
<pre><code class="hljs css language-shell">git clone https://github.com/&lt;Github account&gt;/singa.git
git remote add upstream https://github.com/apache/singa.git
</code></pre></li>
<li><p>创建一个新的分支(例如 <code>feature-foo</code><code>fixbug-foo</code>),在这个分支上工作并提交你的代码:</p>
<pre><code class="hljs css language-shell">git checkout dev
git checkout -b feature-foo
<span class="hljs-meta">#</span><span class="bash"> write your code</span>
git add &lt;created/updated files&gt;
git commit
</code></pre>
<p>commit信息应包括:</p>
<ul>
<li>一个概括性的标题。</li>
<li>详细的描述。如果提交是为了修复bug,描述中最好包括问题的简短复现;如果是新功能,可以描述新功能的动机/目的。</li>
</ul>
<p>如果您的分支有很多小的commit,您需要通过:</p>
<pre><code class="hljs css language-shell">git rebase -i &lt;commit id&gt;
</code></pre>
<p>你可以<a href="https://help.github.com/en/articles/about-git-rebase">压制和重写</a>提交的内容。</p></li>
<li><p>当你在写代码的时候,SINGA的<code>dev</code>分支可能已经被别人更新了;在这种情况下,你需要拉取最新的<code>dev</code>分支:</p>
<pre><code class="hljs css language-shell">git checkout dev
git pull upstream dev:dev
</code></pre></li>
<li><p><code>feature-foo</code> <a href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing">rebase</a><code>dev</code>分支上,并将提交的内容推送到自己的Github账户(你刚刚创建的新分支),rebase操作是为了清理提交历史。提交当前工作后,应执行以下 git 指令:</p>
<pre><code class="hljs css language-shell">git checkout feature-foo
git rebase dev
git push origin feature-foo:feature-foo
</code></pre>
<p>Rebase命令的<a href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing">操作步骤</a>如下: &quot;这个操作的工作原理是进入到两个分支(你所在的分支和你要rebase的分支)的共同来源 -&gt; 获取你所在分支的每次commit所引入的差异 -&gt; 将这些差异保存到临时文件中 -&gt; 将当前分支重置为与你要rebase的分支相同的commit -&gt; 最后依次修改每个差异。&quot;</p>
<p>因此,执行后,你还是在特性分支上,但你自己的提交ID/hash被改变了,因为diffs是在rebase时提交的;而且你的分支现在有来自<code>dev</code>分支和你自己分支的最新代码。</p></li>
<li><p>在 Github 网站上创建一个针对 apache/singa <code>dev</code>分支的pull request(PR)。如果你想通知其他在相同文件上工作过的贡献者,你可以在Github上找到文件,然后点击 &quot;Blame&quot;,就可以看到最后修改代码的人的逐行注释。然后,你可以在PR描述中加上@username,就可以立即ping到他们。请说明该贡献是你的原创作品,并且你在项目的开源许可下将该作品授权给项目。你的新分支的进一步提交(例如,bug修复)将由Github自动添加到这个pull request中。</p></li>
<li><p>接下来等待committer审核PR。在这段时间里,SINGA的<code>dev</code>可能已经被其他人更新了,这时你需要<a href="https://docs.fast.ai/dev/git.html#how-to-keep-your-feature-branch-up-to-date">合并</a>最新的<code>dev</code>来解决冲突。有些人将PR重新<a href="https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request">rebase到最新的dev</a>上,而不是合并。但是,如果其他开发者获取这个PR来添加新的功能,然后再发送PR,那么rebase操作会在未来的PR中引入<strong>重复的提交</strong>(不同的哈希)。关于何时避免使用rebase的细节,请参见<a href="https://www.atlassian.com/git/tutorials/merging-vs-rebasing">The Golden Rule of Rebasing</a>。另一种简单的更新PR的方法(修复冲突或提交错误)是,从Apache SINGAS repo的最新开发分支中checkout出一个新的分支,复制并粘贴更新/添加的代码,然后commit并发送一个新的PR。</p></li>
</ol>
<h2><a class="anchor" aria-hidden="true" id="对于committers"></a><a href="#对于committers" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>对于Committers</h2>
<p>Committer可以将PR合并到上游 repo 的 dev 分支。在合并每一个PR之前,提交者应该做到:</p>
<ul>
<li>检查commit信息(内容和格式)</li>
<li>检查对现有代码的修改,API的变化应该被记录下来</li>
<li>检查Travis测试结果,检查代码/文档格式和单元测试。</li>
</ul>
<p>合并PR的方式有两种:</p>
<ul>
<li><p>在Github上,按照<a href="https://gitbox.apache.org/setup/">说明</a>将你的Apache账户与Github账户链接,之后你就可以直接在GitHub上合并PR了。</p></li>
<li><p>通过命令行合并pull request到<a href="https://github.com/apache/singa/pull/xxx">https://github.com/apache/singa/pull/xxx</a>,应执行以下指令:</p>
<pre><code class="hljs css language-shell">git clone https://github.com/apache/singa.git
git remote add asf https://gitbox.apache.org/repos/asf/singa.git
git fetch origin pull/xxx/head:prxxx
git checkout dev
git merge --no-ff prxxx
git push asf dev:dev
</code></pre>
<p>不要使用rebase来合并PR,并禁用fast forward。</p></li>
</ul>
</span></div></article></div><div class="docs-prevnext"></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#对于开发者">对于开发者</a></li><li><a href="#对于committers">对于Committers</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/singa-logo-square.png" alt="Apache SINGA" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/installation">Getting Started</a><a href="/docs/device">Guides</a><a href="/en/https://apache-singa.readthedocs.io/en/latest/">API Reference</a><a href="/docs/examples">Examples</a><a href="/docs/download-singa">Development</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="/docs/history-singa">SINGA History</a><a href="/docs/team-list">SINGA Team</a><a href="/blog">SINGA News</a><a href="https://github.com/apache/singa">GitHub</a><div class="social"><a class="github-button" href="https://github.com/apache/singa" data-count-href="/apache/singa/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">apache/singa-doc</a></div><div class="social"><a href="https://twitter.com/ApacheSINGA" class="twitter-follow-button">Follow @ApacheSINGA</a></div></div><div><h5>Apache Software Foundation</h5><a href="https://apache.org/" target="_blank" rel="noreferrer noopener">Foundation</a><a href="http://www.apache.org/licenses/" target="_blank" rel="noreferrer noopener">License</a><a href="http://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noreferrer noopener">Sponsorship</a><a href="http://www.apache.org/foundation/thanks.html" target="_blank" rel="noreferrer noopener">Thanks</a><a href="http://www.apache.org/events/current-event" target="_blank" rel="noreferrer noopener">Events</a><a href="http://www.apache.org/security/" target="_blank" rel="noreferrer noopener">Security</a></div></section><div style="width:100%;text-align:center"><a href="https://apache.org/" target="_blank" rel="noreferrer noopener" class="ApacheOpenSource"><img src="/img/asf_logo_wide.svg" alt="Apache Open Source"/></a><section class="copyright" style="max-width:60%;margin:0 auto">Copyright © 2023
The Apache Software Foundation. All rights reserved.
Apache SINGA, Apache, the Apache feather logo, and
the Apache SINGA project logos are trademarks of The
Apache Software Foundation. All other marks mentioned
may be trademarks or registered trademarks of their
respective owners.</section></div></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
document.addEventListener('keyup', function(e) {
if (e.target !== document.body) {
return;
}
// keyCode for '/' (slash)
if (e.keyCode === 191) {
const search = document.getElementById('search_input_react');
search && search.focus();
}
});
</script><script>
var search = docsearch({
apiKey: '45202133606c0b5fa6d21cddc4725dd8',
indexName: 'apache_singa',
inputSelector: '#search_input_react',
algoliaOptions: {"facetFilters":["language:en","version:3.0.0"]}
});
</script></body></html>