Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


Automatic merge failed; Git error

Educative Answers Team
svg viewer


An Automatic Merge Failure occurs whenever there are competing changes made to the same line by two developers, or when one developer is working on a file and another developer deletes it. Merge conflicts are relatively common whenever you commit.

It is essential to identify and resolve conflicts. Here is a step-by-step guide on how to deal with Automatic Merge Failure.

Step 1

Open git bash and go to the repository in which the merge conflict arose:

cd {RepositoryName}

Step 2

Write git status to generate a list of files that have a merge conflict.

Step 3

Open the highlighted file using the git status command in an IDEAn integrated development environment is a software application that provides comprehensive facilities for software development, and search for conflict markers: <<<<<<<, =======, and <<<<<<<.

You will find something like this:

<<<<<<< HEAD
>>>>>>> branch-ed
  • <<<<<<< HEAD shows the change made from the base branch.
  • ======= separates the conflicts.
  • >>>>>>> branch-ed shows the branch where the conflicting change was made.

In this example, there is a conflict in the same line of code; the base branch wrote abc123, whereas, the branch branch-ed wrote def456.

Step 4

Decide which version you want to incorporate: base branch one, sub-branch one, both, or a new one. Make the changes to the file and save them.

Suppose you want to change the branch-ed: go to that branch, change def456 to abc123, and save the file. Add the file as you go:

git add

Step 5

Commit your changes and add a comment to highlight the change made manually:

git commit -m "Changed branch-ed from def123 to abc123"


Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring