Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. How to use Git
  6. How to use Git on Windows
  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.

Right-click on the “tutorial” directory and select “Pull”.

Click Pull from right-click menu.

Click “OK.”

Click OK button

If you see an info box teaching you about merges, read it and click “OK”.

The message automatic merge failed comes up

When you see the warning message that the automatic merge has failed, click “Close”.

Click Close button

You will then be asked if you would like to see the changes in this revision. Click “Yes”.

Click Yes button

TortoiseGit is telling us that the automatic merge has failed because “sample.txt” has a merge conflict. Click “OK”.

The conflicts have happened.

When you open sample.txt, 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.

Right-click and choose Git Commit -> ‘main.’

A window about merges will display; click “OK”.

A window about merges

Right-click the sample file and choose “Resolved,” since we just resolved this merge conflict manually using our text editor.

Right-click the sample file and choose Resolved

When a window displays to confirm this change, click “Yes.”

a window displays to confirm this change

When warned about the commit message still mentioning the conflicting files, choose “Ignore” or “Abort.” Then remove the lines from the commit message or follow the advice at the bottom to have TortoiseGit automatically remove lines starting with a “#” for you. (Automatically removing these is the default behavior for most other Git clients.)

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 Mac or Command Line next, head straight to the branching section.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life