You want to work on a piece of code that has the potential to break things, create the branch test_code.
你想要修改一處代碼,在修改過程中可能會引起一些問題,所以要創(chuàng)建一個分支 test_code 來修改。
接下來的10關(guān)都和分支有關(guān)。 如果你想在不影響主線的情況下進行安全的開發(fā),就要以主線為基礎(chǔ)創(chuàng)建一個分支,然后在分支上修改,最后再把分支合并到主線上。實際上,一般情況下都是在分支上工作的,因為在一個團隊中,你和你的伙伴共享主線,直接在主線下工作會影響其他人,所以每個人都分別在各自的分支上工作。
分支的常用命令如下:
$ git branch branch-name
$ git branch
第1條語句用于創(chuàng)建分支,branch-name 就是你要創(chuàng)建的分支名稱;第2條語句用于列出全部分支。
第31關(guān)過關(guān)畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-31-branch.png" alt="第31關(guān) branch" />