Создание конфликта
Когда возникает конфликт, вам нужно будет его разрешить, чтобы выполнить работу. На этом этапе мы намеренно создадим конфликт, используя два наших существующих репозитория, «tutorial» и «tutorial2».
Сначала откройте файл sample.txt
в каталоге tutorial
. Добавьте выделенный ниже жирный текст в файл и зафиксируйте его.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
![Record the status of commit index](/static/4e9a8f49ec25d1845324f70ea1eab76b/5a190/01.png)
Затем откройте файл sample.txt
в каталоге tutorial2
. Добавьте выделенный ниже жирный текст в файл и зафиксируйте его.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
pull: Obtain the content of the remote repository
![pull Acquire the contents of a remote repository.](/static/872e42c66e37b3235eba483a2d018be7/5a190/02.png)
Теперь передайте изменение из tutorial2
в удаленный репозиторий.
![Push to the remote repository](/static/16e668f363254db234adcd68f556befa/5a190/03.png)
В нашем текущем удаленном репозитории файл sample.txt
содержит третью строку pull: Obtain the content of the remote repository
и зафиксирован в журнале.
Далее мы собираемся передать фиксацию из нашего репозитория tutorial
в удаленный репозиторий.
![Git raises a conflict and rejects your push](/static/aad1db1136d67488d3905f317fd9b91f/5a190/04.png)
Как видите, Git обнаруживает конфликт и отклоняет ваш запрос.