Параллельная работа
Ветвление позволяет нам работать в нескольких параллельных рабочих пространствах.
Чтобы продемонстрировать это, давайте создадим две ветки: одну с именем issue2
, а другую с именем issue3
. Затем переключимся на ветку issue2
.
$ git branch issue2
$ git branch issue3
$ git checkout issue2
Switched to branch 'issue2'
$ git branch
* issue2
issue3
main
На данный момент наш журнал выглядит так:
![Current history](/static/9720ce5e51d99223c6439ab12e95ce76/5a190/01.png)
Далее добавьте выделенный ниже жирный текст в файл 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](/static/b1ead0447500547ef87cd9ae5cf25685/5a190/02.png)
Далее переключитесь на ветку 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
И зафиксируйте изменение с помощью команды 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(-)
Теперь наш журнал выглядит так:
![Current history](/static/9a5d87d3fd3b7864b180595f917c3c70/5a190/03.png)
Мы добавили две разные строки текста в две разные ветки параллельно.