mirror of
https://github.com/danielkummer/git-flow-cheatsheet.git
synced 2024-11-22 07:54:03 +01:00
387 lines
15 KiB
HTML
387 lines
15 KiB
HTML
<!doctype html>
|
||
<html lang="zh-TW">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||
<title>git-flow 備忘清單</title>
|
||
<link href='https://fonts.googleapis.com/css?family=Sansita+One' rel='stylesheet' type='text/css'>
|
||
<link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen,print">
|
||
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen,print">
|
||
<link rel="stylesheet" href="css/style.zh_TW.css" type="text/css" media="screen,print">
|
||
|
||
<script type="text/javascript">
|
||
var _gaq = _gaq || [];
|
||
_gaq.push(['_setAccount', 'UA-33766650-1']);
|
||
_gaq.push(['_trackPageview']);
|
||
|
||
(function () {
|
||
var ga = document.createElement('script');
|
||
ga.type = 'text/javascript';
|
||
ga.async = true;
|
||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||
var s = document.getElementsByTagName('script')[0];
|
||
s.parentNode.insertBefore(ga, s);
|
||
})();
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<div id="banner"><a href="https://github.com/danielkummer/git-flow-cheatsheet">Fork me on GitHub</a></div>
|
||
<header>
|
||
|
||
<h1 id="title" style="font-size: 80px;">git-flow 備忘清單</h1>
|
||
|
||
<p id="author">
|
||
由 <a href="http://twitter.com/0r1g4m14dd1c7" target="_blank">Daniel Kummer (<a href="https://twitter.com/share" data-size="large">Tweet</a>)</a> 建立
|
||
|
||
</p>
|
||
<p id="desc">使用 git-flow 進行高效率的分支使用。 by <a href="http://nvie.com/" target="_blank">Vincent Driessen</a></p>
|
||
<p id="translations">翻譯:
|
||
<a href="index.html" title="english">English</a> -
|
||
<a href="index.es_ES.html" title="spanish">Castellano</a> -
|
||
<a href="index.pt_BR.html" title="Brazilian Portugues">Brazilian Portugues</a> -
|
||
<a href="#" class="active" title="Traditional Chinese">繁體中文(Traditional Chinese)</a> -
|
||
<a href="index.zh_CN.html" title="Simplified Chinese">简体中文(Simplified Chinese)</a><br />
|
||
<a href="index.ja_JP.html" title="日本語">日本語</a> -
|
||
<a href="index.tr_TR.html" title="Turkce">Türkçe</a> -
|
||
<a href="index.ko_KR.html" title="한국어">한국어(Korean)</a> -
|
||
<a href="index.fr_FR.html" title="Français">Français</a> -
|
||
<a href="index.it_IT.html" title="Italiano">Italiano</a> -
|
||
<a href="index.nl_NL.html" title="Nederlands">Nederlands</a> -
|
||
<a href="index.ru_RU.html" title="Russian">Русский (Russian)</a> -
|
||
<a href="index.de_DE.html" title="German">Deutsch (German)</a> -
|
||
<a href="index.ca_CA.html" title="Català">Català (Catalan)</a> -
|
||
<a href="index.ro_RO.html" title="Romanian">Română (Romanian)</a> -
|
||
<a href="index.el_GR.html" title="Ελληνικά (Greek)">Ελληνικά (Greek)</a> -
|
||
<a href="index.uk_UA.html" title="Ukrainian">Українська (Ukrainian)</a> -
|
||
<a href="index.vi_VN.html" title="Tiếng Việt">Tiếng Việt (Vietnamese)</a> -
|
||
<a href="index.pl_PL.html" title="Polish">Polski</a> -
|
||
<a href="index.ar_MA.html" title="العربية">العربية</a> -
|
||
<a href="index.fa_FA.html" title="فارسی">فارسی</a> -
|
||
<a href="index.az_AZ.html" title="Polish">Azərbaycanca (Azerbaijani)</a>
|
||
<a href="index.id_ID.html" title="Bahasa Indonesia">Bahasa Indonesia</a>
|
||
</p>
|
||
</header>
|
||
|
||
<div id="main">
|
||
|
||
|
||
<div class="scrollblock">
|
||
<h2>什麼是 git-flow ?</h2>
|
||
|
||
<p>
|
||
git-flow 是一個 git 擴充功能,依照 Vincent Driessen 的分支模型提供高層次的倉庫控制方式。
|
||
<small><a href="http://nvie.com/posts/a-successful-git-branching-model/">查看更多</a></small>
|
||
</p>
|
||
<p class="divider">★ ★ ★</p>
|
||
|
||
<p>這個備忘清單將會為您展示 git-flow 的基本操作方式與結果。</p>
|
||
|
||
<p class="divider">★ ★ ★</p>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<h2>基礎提示</h2>
|
||
<ul>
|
||
<li>git-flow 提供了極為出色的指令與輸出提示。請仔細閱讀並觀察發生了什麼事情...</li>
|
||
<li><a href="http://www.sourcetreeapp.com/">SourceTree</a> 是一個極為出色的 git 圖形介面應用程式,以內建了 git-flow 的功能。(支援 Mac OS X 與 Windows)</li>
|
||
<li>git-flow 是一個以合並(Merge)概念為基底的解決方案,它並無提供重置(rebase)特性分支的功能。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
</div>
|
||
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="setup" href="#setup">安裝</a></h2>
|
||
<ul>
|
||
<li>你需要有一個已經初始化的 git 倉庫。</li>
|
||
<li>git-flow 可以在 macOS、Linux 和 Windows 之下使用。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
<div class="col-1">
|
||
<h3>Mac OS X</h3>
|
||
<span>透過 Homebrew 安裝</span>
|
||
<blockquote>
|
||
$ brew install git-flow-avh
|
||
</blockquote>
|
||
<span>透過 Macports 安裝</span>
|
||
<blockquote>
|
||
$ port install git-flow-avh
|
||
</blockquote>
|
||
<h3>Linux</h3>
|
||
<blockquote>
|
||
$ apt-get install git-flow
|
||
</blockquote>
|
||
<h3>Windows (Cygwin)</h3>
|
||
<blockquote>
|
||
$ wget -q -O - --no-check-certificate
|
||
https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash
|
||
</blockquote>
|
||
<p>在 Windows 下安装 git-flow, 你會需要 wget 和 util-linux。</p>
|
||
</div>
|
||
<div class="col-2">
|
||
<p>
|
||
更詳細的 git-flow 安裝指南,請參閱 <a href="https://github.com/petervanderdoes/gitflow-avh/wiki/Installation" target="_blank">git flow wiki</a>.
|
||
</p>
|
||
<img src="img/download.png" alt="install git-flow"/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="getting_started" href="#getting_started">開始 git-flow</a></h2>
|
||
<p>在開始使用 git-flow 之前,你必須完成一些簡單的設定。</p>
|
||
<p class="divider">★ ★ ★</p>
|
||
<div class="col-1">
|
||
<h3>初始化</h3>
|
||
|
||
<p>開始使用 git-flow 前,你必須切換目錄至你的 git 專案中,並且以下列指令進行初始化:</p>
|
||
<blockquote>
|
||
git flow init
|
||
</blockquote>
|
||
<p>
|
||
接著您必須回答幾個問題,是關於分支名稱的定義。<br/>這裡建議使用預設值。
|
||
</p>
|
||
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="initialize"></div>
|
||
<div class="lines-small"></div>
|
||
<div class="lines-open"></div>
|
||
<div class="lines-big"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="features" href="#features">新功能分支(Feature)</a></h2>
|
||
|
||
<ul class="narrow">
|
||
<li>為接下即將發佈的版本開發新功能時使用。</li>
|
||
<li>通常新功能分支只會存於開發者機器上。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
|
||
<div class="col-1">
|
||
<h3>開始新功能設計</h3>
|
||
<p>新功能的開發是由 'develop' 分支的最後一個版本發展出來的。</p>
|
||
<p>使用下列的命令可以開始一個新功能的分支:</p>
|
||
<blockquote>
|
||
git flow feature start MYFEATURE
|
||
</blockquote>
|
||
<p>這個命令將會於 'develop' 的最後一個版本建立出另一個 'feature/MYFEATURE' 分支,並自動切換至這個分支底下。現在你可以開始製作新功能。</p>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="feature-start"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<div class="col-1">
|
||
<h3>完成新功能</h3>
|
||
|
||
<p>當你在新功能分支完成新功能後,使用下列指令來結束新功能開發:
|
||
</p>
|
||
<blockquote>
|
||
git flow feature finish MYFEATURE
|
||
</blockquote>
|
||
<p>這個指令會替你完成下列動作:
|
||
<ul>
|
||
<li>合並(Merge) MYFEATURE 分支回到 'develop'</li>
|
||
<li>刪除這個新功能分支</li>
|
||
<li>切換回 'develop' 分支</li>
|
||
</ul>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="feature-end"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<div class="col-1">
|
||
<h3>發佈新功能分支</h3>
|
||
|
||
<p>
|
||
你是否需多人合作開發新功能?<br/>
|
||
透過下列命令來發佈新功能分支到遠端 git 伺服器,讓其他使用者也能共用這個新功能分支。
|
||
</p>
|
||
|
||
<blockquote>
|
||
git flow feature publish MYFEATURE
|
||
</blockquote>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="feature-publish"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<div class="col-1">
|
||
<h3>取得新功能分支</h3>
|
||
|
||
<p>
|
||
當你需接手完成新功能時,透過下列命令取得遠端伺服器上的新功能分支,並得到所有保存在遠端伺服器上的變更紀錄:
|
||
</p>
|
||
|
||
<blockquote>
|
||
git flow feature pull MYFEATURE
|
||
</blockquote>
|
||
|
||
<p>
|
||
你也可以透過下列指令進而追蹤一個功能:
|
||
</p>
|
||
|
||
<blockquote>
|
||
git flow feature track MYFEATURE
|
||
</blockquote>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="feature-pull"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="release" href="#release">製作發佈版本(release)</a></h2>
|
||
|
||
<ul>
|
||
<li>用於支援準備發佈正式產品前的預備分支。</li>
|
||
<li>允許修正小問題,並為發布版本準備或修改中介資料。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
<div class="col-1">
|
||
<h3>開始推出新版本</h3>
|
||
|
||
<p>使用下列指令準備推出(release)新版本分支:</p>
|
||
<blockquote>
|
||
git flow release start RELEASE [BASE]
|
||
</blockquote>
|
||
<p>
|
||
它會從 'develop' 分支的最後一個版本創建出 release 分支。
|
||
</p>
|
||
<p>你也可以選擇性的加入一個 sha-1 hash 於<code>[BASE]</code>參數,這會讓 release 分支於您指定的 develop 提交紀錄點產生分支。有一點需要注意的是,sha-1 hash 只能是於'develop' 分支下。</p>
|
||
<p class="divider">★ ★ ★</p>
|
||
<p>最佳的狀況下,在創建出新的 release 分支後,應要立即的發布至遠端伺服器上,讓其他團隊中的開發者也能存取這個 release 分支。而這個發布指令很類似於發布新功能:</p>
|
||
<blockquote>
|
||
git flow release publish RELEASE
|
||
</blockquote>
|
||
<p>(您也可以透過 <br/><code>git flow release track RELEASE</code> 指令來取得 release 版本的遠端更改)</p>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="release-start"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<div class="col-1">
|
||
<h3>完成推出新版本</h3>
|
||
|
||
<p>完成 release 版本是一個很大的 git 分支操作。但你只許要執行下列指令:</p>
|
||
<blockquote>
|
||
git flow release finish RELEASE
|
||
</blockquote>
|
||
<p>git flow 會幫你執行下面幾個步驟:</p>
|
||
<ul>
|
||
<li>合並 release 分支到 'master'</li>
|
||
<li>在 master 加上版本號標籤<small>(Tag)</small></li>
|
||
<li>合並 release 分支到 'develop'</li>
|
||
<li>移除 release 分支</li>
|
||
</ul>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="release-end"></div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="hotfixes" href="#hotfixes">快速修復(hotfix)</a></h2>
|
||
|
||
<ul>
|
||
<li>當你的產品發佈環境處於不可預期的狀況,且發生了一些需要立即修正的問題,您可以使用 hotfix 來幫助您。</li>
|
||
<li>hotfix 是從 master 中加入的版本標籤開始。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
<div class="col-1">
|
||
<h3>開始快速修復</h3>
|
||
|
||
<p>快速修復(hotfix)就像其他的 git flow 指令一樣,您可以透過下列指令開始:</p>
|
||
<blockquote>
|
||
git flow hotfix start VERSION [BASENAME]
|
||
</blockquote>
|
||
<p>你必須填寫一個 VERSION 參數,這代表當你完成 hotfix 時發佈的版本號碼。</p>
|
||
<p>此外你可以自由挑選修復開始的分支名稱<code>[BASENAME]</code>,分支名稱如果不填寫的狀況下,預設是 'master'。</p>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="hotfix-start"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<div class="col-1">
|
||
<h3>完成快速修復</h3>
|
||
|
||
<p>當你在快速修復分支完成修復後,透過下列的指令讓修復分支合並回 develop 和 master 分支。並且在 master 分支加上修訂版本號的標籤(tag):</p>
|
||
<blockquote>
|
||
git flow hotfix finish VERSION
|
||
</blockquote>
|
||
</div>
|
||
<div class="col-2">
|
||
<div class="hotfix-end"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div>
|
||
<div class="col-1"></div>
|
||
<div class="col-2">
|
||
<div class="lines-close"></div>
|
||
<div class="lines-small-end"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="scrollblock">
|
||
<h2><a name="commands" href="#commands">指令一覽圖</a></h2>
|
||
<img src="img/git-flow-commands.png" alt="git-flow commands"/>
|
||
</div>
|
||
|
||
<div class="scrollblock">
|
||
<h2>備註</h2>
|
||
<p class="divider">★ ★ ★</p>
|
||
<ul>
|
||
<li>這裡我們只介紹了重要且常用的功能,並非包含所有的指令。</li>
|
||
<li>git-flow 只是一個額外的擴充功能,即使安裝了 git-flow 後你依然可以使用你所知道的原生 git 指令。</li>
|
||
<li>'support' 分支目前為測試版本不建議使用。</li>
|
||
<li>如果你很樂意提供翻譯,我很樂意整合。</li>
|
||
</ul>
|
||
<p class="divider">★ ★ ★</p>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<footer>
|
||
<div class="scrollblock">
|
||
<h2><a name="comments" href="#comments">建議與回應</a></h2>
|
||
|
||
<div id="disqus_thread"></div>
|
||
</div>
|
||
</footer>
|
||
<script type="text/javascript">
|
||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
||
var disqus_shortname = 'gitflowcheatsheet'; // required: replace example with your forum shortname
|
||
|
||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||
(function () {
|
||
var dsq = document.createElement('script');
|
||
dsq.type = 'text/javascript';
|
||
dsq.async = true;
|
||
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
|
||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||
})();
|
||
</script>
|
||
<noscript>請允許你的瀏覽器使用 JavaScript 才能看得到<a href="http://disqus.com/?ref_noscript">建議與回應 powered by Disqus.</a>
|
||
</noscript>
|
||
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
||
|
||
</body>
|
||
</html>
|