Создание конфликта
Когда возникает конфликт, вам нужно будет его разрешить, чтобы выполнить работу. На этом этапе мы намеренно создадим конфликт, используя два наших существующих репозитория, «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
$ git add sample.txt
$ git commit -m "append description of the commit command"
  [main 95f15c9] append description of the commit command
    1 files changed, 1 insertions(+), 0 deletions(-)
Затем откройте файл 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
$ git add sample.txt
$ git commit -m "append description of the pull command"
  [main 4c01823] append description of the pull command
    1 files changed, 1 insertions(+), 0 deletions(-)
Теперь используйте команду git push, чтобы передать изменение из «tutorial2» в удаленный репозиторий.
$ git push
  Username: <username>
  Password: <password>
  Counting objects: 5, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (2/2), done.
  Writing objects: 100% (3/3), 391 bytes, done.
  Total 3 (delta 0), reused 0 (delta 0)
  To https://example.backlog.com/git/BLGGIT/tutorial.git
      3da09c1..4c01823  main -> main
В нашем текущем удаленном репозитории файл sample.txt содержит третью строку pull: Obtain the content of the remote repository и зафиксирован в журнале.
Далее мы собираемся передать фиксацию из нашего репозитория tutorial в удаленный репозиторий.
$ git push
  Username: <username>
  Password: <password>
  To https://example.backlog.com/git/BLGGIT/tutorial.git
  ! [rejected]        main -> main (non-fast-forward)
  error: failed to push some refs to 'https://example.backlog.com/git/BLGGIT/tutorial.git'
  To prevent you from losing history, non-fast-forward updates were rejected
  Merge the remote changes (e.g. 'git pull') before pushing again.  See the
  'Note about fast-forwards' section of 'git push --help' for details.
Как видите, Git обнаруживает конфликт и отклоняет ваш запрос.