Make a conflict
When a conflict arises, you will need to resolve it to complete your work. In this step, we are going to deliberately create a conflict using our two existing repositories, “tutorial” and “tutorial2”.
First, open the sample.txt
file in the tutorial
directory on your machine. Add the bold text below to the file and commit.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
Next, open the sample.txt
file in the tutorial2
directory. Add the bold text below to the file and commit.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
pull: Obtain the content of the remote repository
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 committed in the history log.
Next, we will push the commit from our tutorial
repository to the remote repository.
As you can see, Git raises a conflict and rejects your push.