forked from jlord/git-it
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jlord#95 from fredchu/zhtw-7
Zhtw 7: Branches Aren't Just For Birds
- Loading branch information
Showing
2 changed files
with
44 additions
and
50 deletions.
There are no files selected for viewing
92 changes: 43 additions & 49 deletions
92
guide/raw-content-zhtw/7_branches_arent_just_for_birds.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,98 @@ | ||
<div class="challenge"> | ||
<h2>The Challenge:</h2> | ||
<p>Create a new branch on your fork for your contribution.</p> | ||
<h2>關卡內容:</h2> | ||
<p>在你的 <n>fork</n> 新增 <n>branch</n>。</p> | ||
</div> | ||
|
||
<h2>Branches</h2> | ||
<h2><n>Branches</n></h2> | ||
|
||
<p>Git repositories use branches to isolate work when needed. It's | ||
common practice when working on a project or with others on a | ||
project to create a <strong>branch</strong> to keep your changes in until they are ready. This | ||
way you can do your work while the main, commonly named 'master', | ||
branch stays stable. When your branch is ready, you merge it back into 'master'.</p> | ||
<p><n>Git</n> <n>repositories</n> 用 <n>branches</n> 來隔離進度。當需要跟其他人一起進行專案時,在你完成負責的部份之前,經常需要利用 | ||
<strong><n>branch</n></strong> 來保護你對程式所做的修改。如此,你就可以讓主要的 'master' <n>branch</n> | ||
保持穩定,不被未完成的修改影響。等到你完成在 <n>branch</n> 上的修改,就可以把它 <v>merge</v> 回 'master' <n>branch</n>。</p> | ||
|
||
<img src="../assets/imgs/branches.png" width="600"> | ||
|
||
|
||
<p>For a great visualization on how branches work in a project, see this | ||
GitHub Guide: <a href="http://guides.github.com/overviews/flow/" target="_blank">guides.github.com/overviews/flow</a></p> | ||
<p>在 GitHub Guide 中我們有提供解釋 <n>branches</n> 運作方式的示意圖:<a href="http://guides.github.com/overviews/flow/" target="_blank">guides.github.com/overviews/flow</a></p> | ||
|
||
<h2>GitHub Pages</h2> | ||
<p>GitHub will automatically serve and host static website files in | ||
branches named 'gh-pages'. Since the project you forked creates a | ||
website, its main branch is 'gh-pages' instead of 'master'. All sites like this can be | ||
found using this pattern for the URL: </p> | ||
<p>GitHub 會自動發佈你放在 'gh-pages' <n>branch</n> 裡的靜態檔案,並架設一個網站。由於你 <v>forked</v> | ||
的專案內容是一個網站,所以它的預設 <n>branch</n> 是 'gh-pages' 而不是 | ||
'master'。而你會發現這些網站,網址都長得像這樣:</p> | ||
|
||
<code>http://githubusername.github.io/repositoryname</code> | ||
|
||
<h2>Step: Create a branch</h2> | ||
<p>When you create a branch, Git copies everything from the current | ||
branch you're on and places it in the branch you've requested.</p> | ||
<h2>步驟:新增 <n>branch</n></h2> | ||
<p>當你新增 <n>branch</n> 的時候,Git 會拷貝目前 <n>branch</n> 上所有的檔案到新的 <n>branch</n>。</p> | ||
|
||
<p>Type <code>git status</code> to see what branch you're currently on (it | ||
should be 'gh-pages').</p> | ||
<p>在終端機輸入 <code>git status</code> 可以知道目前你在哪個 <n>branch</n>(應該會在 'gh-pages')。</p> | ||
|
||
<p>Create a branch and name it "add-<username>", where 'username' is | ||
your username. For instance, "add-jlord". <strong>Branches are case-sensitive so name your branch exactly the way your GitHub name appears</strong>.</p> | ||
<p>新增一個 <n>branch</n> 並命名為 「add-<username>」,請用你的帳號名稱替換掉 'username'。例如「add-jlord」。<strong><n>Branches</n> 的名字有分大小寫,所以請確定輸入的帳號名稱跟 GitHub 上顯示的一模一樣。 </strong></p> | ||
|
||
<p><code>$ git branch <BRANCHNAME></code></p> | ||
|
||
<p>Now you have a branch with a new name identical to 'gh-pages'.</p> | ||
<p>水啦!你擁有了一個全新、內容跟 'gh-pages' 一模一樣的 <n>branch</n>!</p> | ||
|
||
<p>To go into that branch and work on it, similar to using <code>cd</code> to | ||
change directory in terminal, you <strong>checkout</strong> a branch. Go onto your new branch:</p> | ||
<p>就像終端機去另一個資料夾的指令 <code>cd</code> 一樣,請 <strong><v>checkout</v></strong> | ||
到剛才新增的 <n>branch</n>:</p> | ||
|
||
<p><code>$ git checkout <BRANCHNAME></code></p> | ||
|
||
<h2>Step: Create a new file</h2> | ||
<p>Back to the text editor:</p> | ||
<h2>步驟:新增檔案</h2> | ||
<p>接下來我們回到文字編輯器:</p> | ||
<ul> | ||
<li>Create a new file named <span style="white-space: nowrap;">"add-<USERNAME>.txt"</span>, where 'username' is your username. For instance, "add-jlord.txt".</li> | ||
<li>Then, just write your | ||
GitHub username in it, that's it and that's all. For instance, | ||
I'd type 'jlord'.</li> | ||
<li>Save this file in the 'contributors' folder in Patchwork: <strong>Patchwork/contributors/add-yourusername.txt</strong></li> | ||
<li>Next, check in your changes!</li> | ||
<li>新增一個檔案並命名為 <span style="white-space: nowrap;">「add-<USERNAME>.txt」</span>,請用你的帳號名稱替換 'username',像這樣,「add-jlord.txt」。</li> | ||
<li>在檔案裡寫下你的 GitHub 帳號名稱。例如,我就會寫 'jlord'。</li> | ||
<li>將檔案存到在 Patchwork 裡的 'contributors' 資料夾: <strong>Patchwork/contributors/add-yourusername.txt</strong></li> | ||
<li>接著,把你的修改記錄下來!</li> | ||
</ul> | ||
|
||
<h2>Step: Check-in</h2> | ||
<p>Go through the steps for checking in a project: </p> | ||
<h2>步驟:紀錄</h2> | ||
<p>按照以下的步驟,把剛才的修改用 Git 記錄下來:</p> | ||
|
||
<p><code>$ git status</code></p> | ||
<p><code>$ git add <FILENAME></code></p> | ||
<p><code>$ git commit -m 'commit message'</code></p> | ||
|
||
<p>Now push your update to your fork on GitHub:</p> | ||
<p><v>Push</v> 剛才記錄好的修改到 GitHub 上,你的 <adj>forked</adj> <n>repository</n> 裡頭:</p> | ||
|
||
<p><code>$ git push origin <BRANCHNAME></code></p> | ||
|
||
<div class="verify"> | ||
<h3>Verify with </h3> <code>git-it verify </code><br> | ||
<h3>Go to the next challenge </h3> <code>git-it</code> | ||
<h3>確認你完成了所有的步驟:</h3> <code>git-it verify</code><br> | ||
<h3>前往下一關:</h3> <code>git-it</code> | ||
</div> | ||
|
||
<div class="didnt-pass"> | ||
<h2>Didn't Pass?</h2> | ||
<h2><code>git-it verify</code> 的時候沒有通過?</h2> | ||
|
||
<h4>File NOT in contributors folder</h4> | ||
<p> The file you create should inside the existing 'contributors' folder in the Patchwork repository. If you put it somewhere else, simply use Finder or Windows Explorer to move your file into the folder. You can check <code>git status</code> again and you'll find it sees your changes. Stage and then commit "all" (-A) of these changes (additions and deletions) with the commands below.</p> | ||
<p>剛才新增的檔案應該要放到 Patchwork <n>repository</n> 的 'contributors' | ||
資料夾裡。如果不小心放到別的地方,請打開 Finder 或是 Windows 的檔案總管將該檔案移到 | ||
'contributors' 資料夾,然後可以用 <code>git status</code> 看你剛才移動檔案之後所造成的結果。用以下的指令 | ||
<v>Stage</v> 並且 <v>commit</v> 全部的修改(加上 -A,會將新增檔案跟刪除檔案的動作一起記錄下來):</p> | ||
<p><code>$ git add -A</code></p> | ||
<p><code>$ git commit -m "move file into contributors folder"</code></p> | ||
|
||
<h4>Branch name expected: _____</h4> | ||
<p>The branch name should match your user name exactly. To change your branch name:</p> | ||
<h4><n>Branch</n> name expected: _____</h4> | ||
<p><n>Branch</n> 的名字應該要跟你的帳號名稱一模一樣。用以下的指令修改 <n>branch</n> 的名字:</p> | ||
<p><code>$ git branch -M <NEWBRANCHNAME></code></p> | ||
<p>When you've made your updates, verify again!</p> | ||
<p>完成以上的動作之後,再執行一次 <code>git-it verify </code>!</p> | ||
</div> | ||
|
||
<div id="git-tips"> | ||
<h2>Tips</h2> | ||
<h2>撇步</h2> | ||
<ul> | ||
<li>You can create and switch to a branch in one line:</li> | ||
<li>只用一個指令就新增並切換到新的 <n>branch</n>:</li> | ||
<li><code>$ git checkout -b <BRANCHNAME></code></li> | ||
<li>Create a new branch:</li> | ||
<li>新增 <n>branch</n>:</li> | ||
<li><code>$ git branch <BRANCHNAME></code></li> | ||
<li>Move onto a branch:</li> | ||
<li>切換到另一個 <n>branch</n>:</li> | ||
<li><code>$ git checkout <BRANCHNAME></code></li> | ||
<li>List the branches:</li> | ||
<li>列出所有的 <n>branches</n></li> | ||
<li><code>$ git branch</code></li> | ||
<li>Rename a branch you're currently on:</li> | ||
<li>重新命名目前所在的 <n>branch</n></li> | ||
<li><code>$ git branch -m <NEWBRANCHNAME></code></li> | ||
<li>Verify what branch you're working on</li> | ||
<li>看目前正在哪個 <n>branch</n></li> | ||
<li><code>$ git status</code></li> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters