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.

并行作业

分支允许我们在多个并行工作区中工作。

为了演示这一点,让我们创建两个分支,一个名为issue2,另一个名为issue3。然后切换到issue2

$ git branch issue2
$ git branch issue3
$ git checkout issue2
Switched to branch 'issue2'
$ git branch
* issue2
  issue3
  main

此时,我们的历史记录如下:

Current history

接下来,将下面的粗体文本添加到myfile.txt文件中。

Anyone can learn Git with this tutorial and Backlog add: Register a change in an index commit: Save the status of an index

然后提交更改。

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

现在我们的历史记录如下:

Current history

接下来,切换到issue3分支。

$ git checkout issue3
Switched to branch 'issue3'

issue3分支当前与主分支具有相同的历史记录和内容。它不会包括我们刚才所做的更改,因为它已提交给issue2分支。

将下面的粗体文本添加到myfile.txt文件中。

Anyone can learn Git with this tutorial and Backlog add: Register a change in an index pull: Obtain the content of the remote repository

并使用添加命令来提交更改。

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

现在我们的历史记录如下:

Current history

我们已将两行不同的文本,并行添加到两个不同的分支。

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life