Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Cách sử dụng Git
  6. Cách sử dụng phân nhánh trong Git
  7. Làm việc song song
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Làm việc song song

Phân nhánh cho phép chúng ta làm việc trong nhiều không gian làm việc song song.

Để chứng minh điều này, hãy tạo hai nhánh, một nhánh có tên issue2 và một nhánh khác có tên issue3. Sau đó, chuyển sang issue2.

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

Tại thời điểm này, đây là lịch sử của chúng ta:

Current history

Tiếp theo, thêm phần chữ in đậm bên dưới vào tệp 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

Và sau đó cam kết thay đổi.

$ 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(-)

Đây hiện là lịch sử của chúng ta:

Current history

Tiếp theo, chuyển sang nhánh issue3.

$ git checkout issue3
Switched to branch 'issue3'

Nhánh issue3 hiện có cùng lịch sử và nội dung với nhánh chính. Nó sẽ không bao gồm thay đổi chúng ta vừa thực hiện vì nó đã được cam kết với nhánh issue2.

Thêm phần chữ in đậm bên dưới vào tệp 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

Và cam kết thay đổi bằng lệnh add.

$ 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(-)

Đây hiện là lịch sử của chúng ta:

Current history

Chúng ta đã thêm hai dòng văn bản khác nhau vào hai nhánh khác nhau song song.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life