Select your PC environment:
In this tutorial, we are going to learn how to resolve a conflict. In order to do that, we are going to start off by deliberately creating a conflict using our two existing repositories, "tutorial" and "tutorial 2".
Windows
Working in tutorial.
First, open the "sample.txt" file in the "tutorial" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
add: Register a change in an index
commit: Save the status of an index

Working in tutorial 2
Next, open the "sample.txt" file in the "tutorial2" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
add: Register a change in an index
pull: Obtain the content of the remote repository

Working in tutorial 2
Now push the change from "tutorial2" to the remote repository.

In our current remote repository, the "sample.txt" file contains the third line "pull: Obtain the content of the remote repository" and has been commited in the history log.
Working in tutorial.
Now, we are going to push the commit from our "tutorial" repository to the remote repository.

Mac
Working in tutorial.
First, open the "sample.txt" file in the "tutorial" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
add: Register a change in an index
commit: Save the status of an index

Working in tutorial 2
Next, open the "sample.txt" file in the "tutorial2" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
add: Register a change in an index
pull: Obtain the content of the remote repository

Working in tutorial 2
Now push the change from "tutorial2" to the remote repository.

In our current remote repository, the "sample.txt" file contains the third line "pull: Obtain the content of the remote repository" and has been commited in the history log.
Working in tutorial.
Now, we are going to push the commit from our "tutorial" repository to the remote repository.

Command Line
Working in tutorial.
First, open the "sample.txt" file in the "tutorial" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
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"
[master 95f15c9] append description of the commit command
1 files changed, 1 insertions(+), 0 deletions(-)
Working in tutorial 2
Next, open the "sample.txt" file in the "tutorial2" directory. Add the bold text below to the file and commit.
Git commands even a monkey can understand
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"
[master 4c01823] append description of the pull command
1 files changed, 1 insertions(+), 0 deletions(-)
Working in tutorial 2
Now push the change from "tutorial2" to the remote repository.
$ 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://monkey.backlogtool.com/git/BLGGIT/tutorial.git
3da09c1..4c01823 master -> master
In our current remote repository, the "sample.txt" file contains the third line "pull: Obtain the content of the remote repository" and has been commited in the history log.
Working in tutorial.
Now, we are going to push the commit from our "tutorial" repository to the remote repository.
$ git push
Username: <username>
Password: <password>
To https://monkey.backlogtool.com/git/BLGGIT/tutorial.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://monkey.backlogtool.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.
As you can see, Git will raise a conflict and reject your push.