Resolve a conflict
To proceed to push the change we just made to the remote repository, we must manually resolve the conflict. To do this, let’s execute a pull to acquire the most recent change set from the remote repository.
Click “Pull” on the toolbar menu.
Click “OK.”
A dialog will pop up warning us of a merge conflict. Close it, then click “Cancel” to cancel pulling.
Git can’t complete the pull because it can’t automatically merge the files that have conflicts. The latest changes in the remote branch have been downloaded to your machine, but your working tree hasn’t been updated. To complete the pull, you have to resolve the conflicts first.
Select the latest commit in your local branch, and click “Merge” then “OK.”
Sourcetree will inform you that there are merge conflicts. Click “OK.”
Now when you open sample.txt
in the tutorial
folder, you will see markers added by Git indicating conflicts in that file section, as shown below.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
<<<<<<< HEAD
commit: Save the status of an index
=======
pull: Obtain the content of the remote repository
>>>>>>> 17c860612953c0f9d88f313c8dfbf7d858e02e91
We are going to resolve the conflict by accepting both changes and removing the marker.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
pull: Obtain the content of the remote repository
Once we have resolved the conflict and the file's content has changed, we will need to initiate a commit.
Select “Uncommitted changes” and choose “Commit”.
We are now updated with the latest change from the remote repository.
This indicates that the two histories successfully merged with the new merge commit. We can now safely push this change to the remote repository without any merge conflicts.
If you don’t want to learn to use Git on Command Line next, head straight to the branching section.