Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. 如何使用 Git
  6. 如何在 Git 中使用分支
  7. 切換到一個分支
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

切換到一個分支

您刚才创建了一个分支;现在您需要切换到该分支,以向其添加新的提交。

使用 git checkout 指令切换到分支issue1

$ git checkout issue1
Switched to branch 'issue1'

現在,歷史紀錄看起來像這樣:

Current history

使用-b選項建立一個新的分支,並用一個指令切換到該分支。

接下來,讓我們新增一個提交。將下面的粗體文本新增到myfile.txt檔案中。

Anyone can learn Git with this tutorial and Backlog add: Register a change in an index

並提交更改。

$ git add myfile.txt
$ git commit -m "append description of the add command"
[issue1 b2b23c4] append description of the add command
 1 files changed, 1 insertions(+), 0 deletions(-)

現在歷史紀錄看起來像這樣:

Current history

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life