Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. How to use Git
  6. How to use Git on Mac
  7. Resolve a conflict
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

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.

Execute pull

Click “OK.”

Click OK button

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.”

click Merge then OK

Sourcetree will inform you that there are merge conflicts. Click “OK.”

Conflict occurred during the merge

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.

Completed acquiring the latest changes 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.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life