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

Project and code management together.

如何在 Git 中使用分支

本教程的前面章节介绍如何设置 Git、创建和克隆存储库、提交和拉取更改等。不管您是否随着教程内容,在 Windows, MacCommand Line 中使用 Git,您现在已经准备好可以学习分支内容了。

如果您错过了我们对分支的介绍,您可以在这里重新温习该内容

如果您还没有,创建一个名为tutorial的新目录,并使用 git init 命令初始化一个 Git 存储库。

$ mkdir tutorial
$ cd tutorial
$ git init
Initialized empty Git repository in /Users/username/Desktop/tutorial/.git/

然后在tutorial目录中创建一个名为myfile.txt的新文件,内容如下,并提交更改。

Anyone can learn Git with this tutorial and Backlog
$ git add myfile.txt
$ git commit -m "first commit"
[main (root-commit) a73ae49] first commit
  1 files changed, 1 insertions(+), 0 deletions(-)
    create mode 100644 myfile.txt

此时,我们的历史记录看起来是这样的。

Current history

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life