github-workflow.html 22 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1" />
  6. <meta name="generator" content="VuePress 2.0.0-rc.14" />
  7. <style>
  8. :root {
  9. --c-bg: #fff;
  10. }
  11. html.dark {
  12. --c-bg: #22272e;
  13. }
  14. html,
  15. body {
  16. background-color: var(--c-bg);
  17. }
  18. </style>
  19. <script>
  20. const userMode = localStorage.getItem('vuepress-color-scheme')
  21. const systemDarkMode =
  22. window.matchMedia &&
  23. window.matchMedia('(prefers-color-scheme: dark)').matches
  24. if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
  25. document.documentElement.classList.toggle('dark', true)
  26. }
  27. </script>
  28. <title>GitHub 工作流程</title><meta name="description" content="">
  29. <link rel="preload" href="/assets/style-BDZmSSuf.css" as="style"><link rel="stylesheet" href="/assets/style-BDZmSSuf.css">
  30. <link rel="modulepreload" href="/assets/app-CmntYhet.js"><link rel="modulepreload" href="/assets/github-workflow.html-DDOKpHFX.js">
  31. <link rel="prefetch" href="/assets/index.html-DhRPs45k.js" as="script"><link rel="prefetch" href="/assets/index.html-BCLmUi-h.js" as="script"><link rel="prefetch" href="/assets/dragonos-community-conference.html-CWqW2Ctw.js" as="script"><link rel="prefetch" href="/assets/index.html-Cs92j2wW.js" as="script"><link rel="prefetch" href="/assets/cheat-sheet.html-DJabuBuk.js" as="script"><link rel="prefetch" href="/assets/code-style.html-Dft_PBAz.js" as="script"><link rel="prefetch" href="/assets/code_of_conduct.html-BRXoVhOx.js" as="script"><link rel="prefetch" href="/assets/expectation.html-D4MbIHpL.js" as="script"><link rel="prefetch" href="/assets/pull-requests.html-CUv4vZRf.js" as="script"><link rel="prefetch" href="/assets/resources.html-D_SKq8b5.js" as="script"><link rel="prefetch" href="/assets/index.html-CaVU4dIR.js" as="script"><link rel="prefetch" href="/assets/annual-reports.html-3Zax109j.js" as="script"><link rel="prefetch" href="/assets/community-membership.html-hG8VE2MV.js" as="script"><link rel="prefetch" href="/assets/dev-group.html-DCqkA65d.js" as="script"><link rel="prefetch" href="/assets/sig-wg-lifecycle.html-BVIdXIwQ.js" as="script"><link rel="prefetch" href="/assets/staff-info.html-J8TenB4n.js" as="script"><link rel="prefetch" href="/assets/index.html-B-cznJ4t.js" as="script"><link rel="prefetch" href="/assets/mentee-guide.html-OSMvyUzd.js" as="script"><link rel="prefetch" href="/assets/mentor-guide.html-DrxyuSxS.js" as="script"><link rel="prefetch" href="/assets/index.html-BwGOSl2V.js" as="script"><link rel="prefetch" href="/assets/index.html-CpIeeGQP.js" as="script"><link rel="prefetch" href="/assets/wg-list.html-NLo8doQM.js" as="script"><link rel="prefetch" href="/assets/index.html-DgSI4vRJ.js" as="script"><link rel="prefetch" href="/assets/sig-charter-guide.html-DcbPGLnG.js" as="script"><link rel="prefetch" href="/assets/index.html-D68EhPQF.js" as="script"><link rel="prefetch" href="/assets/educational-learning-courses.html-DYOCBrG9.js" as="script"><link rel="prefetch" href="/assets/ospp.html-25c83WzB.js" as="script"><link rel="prefetch" href="/assets/project-based-mentorship.html-BxGdnTkl.js" as="script"><link rel="prefetch" href="/assets/index.html-Dn1WaXao.js" as="script"><link rel="prefetch" href="/assets/charter.html-DtsiAJuU.js" as="script"><link rel="prefetch" href="/assets/contributing.html-BpSgDmJn.js" as="script"><link rel="prefetch" href="/assets/index.html-DT5VyEaA.js" as="script"><link rel="prefetch" href="/assets/charter.html-BhtRD8B_.js" as="script"><link rel="prefetch" href="/assets/contributing.html-DnbGEwHd.js" as="script"><link rel="prefetch" href="/assets/index.html-yAAvFzKW.js" as="script"><link rel="prefetch" href="/assets/charter.html-DmjcMf1C.js" as="script"><link rel="prefetch" href="/assets/contributing.html-DvlSk6rP.js" as="script"><link rel="prefetch" href="/assets/index.html-B9Ct9KCJ.js" as="script"><link rel="prefetch" href="/assets/charter.html-Sp9QwJSp.js" as="script"><link rel="prefetch" href="/assets/contributing.html-CtoV8Qqk.js" as="script"><link rel="prefetch" href="/assets/index.html-Ca5-MeJZ.js" as="script"><link rel="prefetch" href="/assets/charter.html-CBaqZrHX.js" as="script"><link rel="prefetch" href="/assets/contributing.html-Bg8pHL-9.js" as="script"><link rel="prefetch" href="/assets/index.html-jw0yVKN0.js" as="script"><link rel="prefetch" href="/assets/charter.html-Qw36XXO7.js" as="script"><link rel="prefetch" href="/assets/contributing.html-HnVPfuc2.js" as="script"><link rel="prefetch" href="/assets/index.html-DP-5am-4.js" as="script"><link rel="prefetch" href="/assets/404.html-BaFtCcSn.js" as="script">
  32. </head>
  33. <body>
  34. <div id="app"><!--[--><div class="vp-theme-container external-link-icon"><!--[--><header class="vp-navbar"><div class="vp-toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a class="route-link" href="/"><img class="vp-site-logo" src="/images/dragonos-full-logo.svg" alt><!----></a></span><div class="vp-navbar-items-wrapper" style=""><!--[--><!--]--><nav class="vp-navbar-items vp-hide-mobile" aria-label="site navigation"><!--[--><div class="vp-navbar-item"><a class="route-link auto-link" href="/" aria-label="首页"><!---->首页<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/governance/" aria-label="社区治理"><!---->社区治理<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/communication/" aria-label="社区交流"><!---->社区交流<!----></a></div><div class="vp-navbar-item"><a class="route-link route-link-active auto-link" href="/contributors/" aria-label="贡献者"><!---->贡献者<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/sigs/" aria-label="SIGs"><!---->SIGs<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/wgs/" aria-label="工作组"><!---->工作组<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/mentorship/" aria-label="导师制"><!---->导师制<!----></a></div><div class="vp-navbar-item"><a class="auto-link external-link" href="https://github.com/DragonOS-Community/community" aria-label="GitHub" rel="noopener noreferrer" target="_blank"><!---->GitHub<!----></a></div><!--]--></nav><!--[--><!--]--><button class="vp-toggle-color-mode-button" title="toggle color mode"><svg class="light-icon" viewbox="0 0 32 32" style=""><path d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z" fill="currentColor"></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z" fill="currentColor"></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg><svg class="dark-icon" viewbox="0 0 32 32" style="display:none;"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></button><!----></div></header><!--]--><div class="vp-sidebar-mask"></div><!--[--><aside class="vp-sidebar"><nav class="vp-navbar-items" aria-label="site navigation"><!--[--><div class="vp-navbar-item"><a class="route-link auto-link" href="/" aria-label="首页"><!---->首页<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/governance/" aria-label="社区治理"><!---->社区治理<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/communication/" aria-label="社区交流"><!---->社区交流<!----></a></div><div class="vp-navbar-item"><a class="route-link route-link-active auto-link" href="/contributors/" aria-label="贡献者"><!---->贡献者<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/sigs/" aria-label="SIGs"><!---->SIGs<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/wgs/" aria-label="工作组"><!---->工作组<!----></a></div><div class="vp-navbar-item"><a class="route-link auto-link" href="/mentorship/" aria-label="导师制"><!---->导师制<!----></a></div><div class="vp-navbar-item"><a class="auto-link external-link" href="https://github.com/DragonOS-Community/community" aria-label="GitHub" rel="noopener noreferrer" target="_blank"><!---->GitHub<!----></a></div><!--]--></nav><!--[--><!--]--><ul class="vp-sidebar-items"><!--[--><li><p tabindex="0" class="vp-sidebar-item vp-sidebar-heading active">贡献者指南 <!----></p><ul style="" class="vp-sidebar-children"><!--[--><li><a class="route-link route-link-active auto-link vp-sidebar-item" href="/contributors/" aria-label="为DragonOS社区作出贡献"><!---->为DragonOS社区作出贡献<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/code-style.html" aria-label="代码风格指南"><!---->代码风格指南<!----></a><!----></li><li><a class="route-link route-link-active auto-link vp-sidebar-item active" href="/contributors/github-workflow.html" aria-label="GitHub 工作流程"><!---->GitHub 工作流程<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/pull-requests.html" aria-label="Pull Requests指南"><!---->Pull Requests指南<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/cheat-sheet.html" aria-label="贡献者备忘录"><!---->贡献者备忘录<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/code_of_conduct.html" aria-label="贡献者行为准则"><!---->贡献者行为准则<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/expectation.html" aria-label="对社区成员的期望"><!---->对社区成员的期望<!----></a><!----></li><li><a class="route-link auto-link vp-sidebar-item" href="/contributors/resources.html" aria-label="社区基础设施"><!---->社区基础设施<!----></a><!----></li><!--]--></ul></li><!--]--></ul><!--[--><!--]--></aside><!--]--><!--[--><main class="vp-page"><!--[--><!--]--><div class="theme-default-content"><!--[--><!--]--><div><h1 id="github-工作流程" tabindex="-1"><a class="header-anchor" href="#github-工作流程"><span>GitHub 工作流程</span></a></h1><p>本文旨在向您介绍DragonOS社区的GitHub工作流程。包括一些用于帮助你维持本地环境与社区上游仓库同步的建议,还有一些git提交规范等等。</p><p><strong>本文以DragonOS主仓库为例,社区的其他仓库亦适用此工作流程</strong></p><nav class="table-of-contents"><ul><li><a aria-current="page" href="/contributors/github-workflow.html#_1-在github上创建一个fork" class="router-link-active router-link-exact-active">1. 在GitHub上创建一个Fork</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_2-克隆主仓库到你的电脑" class="router-link-active router-link-exact-active">2. 克隆主仓库到你的电脑</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_3-创建工作分支" class="router-link-active router-link-exact-active">3. 创建工作分支</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_4-使你的分支与远程最新的代码保持同步" class="router-link-active router-link-exact-active">4. 使你的分支与远程最新的代码保持同步</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_5-提交你的更改" class="router-link-active router-link-exact-active">5. 提交你的更改</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_6-推送到github" class="router-link-active router-link-exact-active">6. 推送到GitHub</a></li><li><a aria-current="page" href="/contributors/github-workflow.html#_7-创建新的pull-request" class="router-link-active router-link-exact-active">7. 创建新的Pull Request</a></li></ul></nav><h2 id="_1-在github上创建一个fork" tabindex="-1"><a class="header-anchor" href="#_1-在github上创建一个fork"><span>1. 在GitHub上创建一个Fork</span></a></h2><ol><li>打开 https://github.com/DragonOS-Community/DragonOS</li><li>点击页面右上角的<code>Fork</code>按钮,在你自己的账户下创建一个fork</li></ol><h2 id="_2-克隆主仓库到你的电脑" tabindex="-1"><a class="header-anchor" href="#_2-克隆主仓库到你的电脑"><span>2. 克隆主仓库到你的电脑</span></a></h2><p>把<strong>主仓库</strong>克隆到你的电脑(注意不是你账户下Fork后的仓库)</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"></span>
  35. <span class="line"><span class="token function">git</span> clone https://github.com/DragonOS-Community/DragonOS</span>
  36. <span class="line"><span class="token comment"># 或者是 git clone [email protected]:DragonOS-Community/DragonOS</span></span>
  37. <span class="line"></span>
  38. <span class="line"><span class="token builtin class-name">cd</span> DragonOS</span>
  39. <span class="line"></span>
  40. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>接着,添加你fork的仓库,假设你的名字叫<code>zhangsan</code>,那么就执行以下命令:</p><p><em>注意替换url为你账号下的仓库的链接</em></p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"></span>
  41. <span class="line"><span class="token function">git</span> remote <span class="token function">add</span> zhangsan https://github.com/zhangsan/DragonOS</span>
  42. <span class="line"><span class="token comment"># 或者是 git remote add zhangsan [email protected]:zhangsan/DragonOS</span></span>
  43. <span class="line"></span>
  44. <span class="line"><span class="token comment"># 设置永远不推送到远程的master分支</span></span>
  45. <span class="line"><span class="token function">git</span> remote set-url <span class="token parameter variable">--push</span> origin no_push</span>
  46. <span class="line"></span>
  47. <span class="line"><span class="token comment"># 确认你设置的远程已经生效</span></span>
  48. <span class="line"><span class="token function">git</span> remote <span class="token parameter variable">-v</span></span>
  49. <span class="line"></span>
  50. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="_3-创建工作分支" tabindex="-1"><a class="header-anchor" href="#_3-创建工作分支"><span>3. 创建工作分支</span></a></h2><p><strong>请记住:</strong> 永远不要在你本地的master分支上进行提交。请保持master分支与社区仓库的master一致。</p><p>在开发之前,需要创建新的分支。每个PR都要使用一个新的、干净的分支。</p><p>首先,请切换到本地的master分支(或者main分支),然后让它与远程同步。</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"><span class="token function">git</span> fetch origin</span>
  51. <span class="line">gir checkout master</span>
  52. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><p>创建你的工作分支:</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> patch-my-feature</span>
  53. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>请注意,分支名字应当能简短的说明这个pr是干啥的。</p><p>接着,你就可以开始开发了!</p><h2 id="_4-使你的分支与远程最新的代码保持同步" tabindex="-1"><a class="header-anchor" href="#_4-使你的分支与远程最新的代码保持同步"><span>4. 使你的分支与远程最新的代码保持同步</span></a></h2><p>在开发过程中,您需要周期性的从社区主仓库合并代码到你本地的工作分支。如果您长期不同步主仓库代码,那么就会产生很多的冲突,甚至导致您的更改难以合并到主仓库。</p><p>在执行以下命令之前,请您先切换到您的开发分支,然后执行以下命令:</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"><span class="token function">git</span> fetch origin</span>
  54. <span class="line"><span class="token function">git</span> rebase origin/master</span>
  55. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><p>请注意,不要使用<code>git pull</code>来合并主仓库代码到你的开发分支。请务必使用以上命令。因为,<code>git pull</code> 会创建merge commits,这会让提交历史变得混乱,使得您的PR的commit历史记录就变得难以理解了。</p><h2 id="_5-提交你的更改" tabindex="-1"><a class="header-anchor" href="#_5-提交你的更改"><span>5. 提交你的更改</span></a></h2><p>一般来说,直接提交就行。</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"><span class="token function">git</span> commit</span>
  56. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>你可能会经常把你的更改进行commit,以便能够回退更改.</p><h2 id="_6-推送到github" tabindex="-1"><a class="header-anchor" href="#_6-推送到github"><span>6. 推送到GitHub</span></a></h2><p>当你的PR已经完成,能够准备进行审查的时候,请你把工作分支推送到你在GitHub上的仓库。</p><p>以上面的远程<code>zhangsan</code>为例,命令如下:</p><div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre class="language-bash"><code><span class="line"><span class="token function">git</span> push zhangsan patch-my-feature</span>
  57. <span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><h2 id="_7-创建新的pull-request" tabindex="-1"><a class="header-anchor" href="#_7-创建新的pull-request"><span>7. 创建新的Pull Request</span></a></h2><ol><li>打开你在GitHub上Fork的仓库 <code>https://github.com/&lt;username&gt;/DragonOS</code></li><li>点击右上角的<code>Compare &amp; Pull Request</code>按钮,然后选择分支<code>patch-my-feature</code>,目标为社区主仓库的<code>master</code>分支(或<code>main</code>分支)。</li><li>关于Pull Request的进一步要求,请查看<a class="route-link" href="/contributors/pull-requests.html">Pull Request流程介绍</a></li></ol></div><!--[--><!--]--></div><footer class="vp-page-meta"><div class="vp-meta-item edit-link"><a class="auto-link external-link label" href="https://github.com/DragonOS-Community/community/edit/master/contributors/github-workflow.md" aria-label="帮助我们改善此页面!" rel="noopener noreferrer" target="_blank"><!--[--><svg class="edit-icon" viewbox="0 0 1024 1024"><g fill="currentColor"><path d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"></path><path d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"></path></g></svg><!--]-->帮助我们改善此页面!<!----></a></div><div class="vp-meta-item git-info"><div class="vp-meta-item last-updated"><span class="meta-item-label">Last Updated: </span><!----></div><div class="vp-meta-item contributors"><span class="meta-item-label">Contributors: </span><span class="meta-item-info"><!--[--><!--[--><span class="contributor" title="email: [email protected]">LoGin</span><!----><!--]--><!--]--></span></div></div></footer><nav class="vp-page-nav" aria-label="page navigation"><a class="route-link auto-link prev" href="/contributors/code-style.html" aria-label="代码风格指南"><div class="hint"><span class="arrow left"></span> Prev</div><div class="link"><span>代码风格指南</span></div></a><a class="route-link auto-link next" href="/contributors/pull-requests.html" aria-label="Pull Requests指南"><div class="hint">Next <span class="arrow right"></span></div><div class="link"><span>Pull Requests指南</span></div></a></nav><!--[--><!--]--></main><!--]--></div><!--[--><!----><!--]--><!--]--></div>
  58. <script type="module" src="/assets/app-CmntYhet.js" defer></script>
  59. </body>
  60. </html>