> For the complete documentation index, see [llms.txt](https://tobyisme.gitbook.io/gitlab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tobyisme.gitbook.io/gitlab/learn-git/di-er-tang-ke-git-de-branch.md).

# 第二堂課 - git 的 branch

git 的 branch 非常不佔空間。它們只是一個指向某個 commit 的 reference，就這麼簡單。所以許多 git 的愛好者會建議：

`早點建立 branch！經常建立 branch！`

因為建立 branch 不怎麼會佔用到硬碟空間或者是記憶體，所以你可以把你目前的工作分成好幾個 branch，這比只用一個 branch 要來的好。

同時使用 branch 和 commit 時，我們待會可以看到兩者如何配合。現在，只要記住使用 branch 其實就是在說：「我想要包含這一次的 commit 以及它的所有 parent 的 commit。」

## 語法如下：

```
git branch 名稱 // 建立一個"名稱"的branch
git checkout 名稱 // 跳到某一個branch上
```
