Finalizing a Merge with git merge --continue

In the previous blogs, we saw how to handle merge conflicts and even how to abort a merge using git merge --abort. But what if you’ve already resolved the conflicts and now want to complete the merge?

That’s exactly where git merge --continue comes in.


Re-Creating the Conflict

Suppose we are on the main branch and try to merge feature2:

git merge feature2

This results in a conflict in hello.txt:

Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Automatic merge failed; fix conflicts and then commit the result.

Fixing the Conflict

Open hello.txt and manually edit the content to resolve the conflict. For example:

Hello World
New line from main branch
New line from feature2 branch

Now stage the resolved file:

git add hello.txt

Using git merge --continue

At this point, you have two choices:

  1. Commit directly:
git commit -m "Resolve conflict in hello.txt"
  1. Use the continue option (recommended):
git merge --continue

Git will then open your editor and ask for a merge commit message:

Merge branch 'feature2'

Save and exit (:wq in Vim). Git will create a new merge commit recording the conflict resolution.


What Happened?

  • git merge --continue is useful because it explicitly tells Git:

    • "I’ve resolved the conflicts."
    • "Now finalize the merge with a commit."
  • Without staging the file first (git add), the command will fail:

error: Committing is not possible because you have unmerged files.
  • Once the file is added and staged, running git merge --continue creates the merge commit.

Summary

  • Run git merge <branch> → conflict occurs.
  • Resolve conflicts manually in the file.
  • Stage resolved files with git add.
  • Use git merge --continue to finalize the merge.
  • Git records a merge commit with your resolution.

Keep Learning 🚀

👉 Subscribe to Learning Ocean – Subscribers get coupon codes for my courses, early access to blogs and courses, and even exclusive YouTube videos.

👉 My YouTube Channel – More videos, more fun, and lots of learning!

👉 📺 Watch this topic in video form

Stay curious, keep coding, and let’s make learning fun together! 🎉