git
merge conflicts
version control
software development
git merge

How do I finish the merge after resolving my merge conflicts?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

After resolving merge conflicts, many developers are unsure how to “finish” the merge cleanly. The process is deterministic: resolve files, stage resolutions, create the merge commit, and verify result before pushing. Most mistakes come from forgetting to stage resolved files or leaving conflict markers in code. A small checklist makes merge completion reliable, especially in large branches with many conflicted files.

Core Sections

1. Check merge state

bash
git status

During conflict resolution, Git reports You have unmerged paths. This confirms merge is still in progress.

2. Resolve all conflicted files

Edit files and remove conflict markers:

text
1<<<<<<< HEAD
2...
3=======
4...
5>>>>>>> feature-branch

Keep the intended final code only.

3. Stage resolved files

bash
git add path/to/file1 path/to/file2
# or stage all resolved files
git add .

Staging tells Git the conflict for each file is resolved.

4. Complete the merge commit

bash
git commit

Git usually opens a default merge message. Save and close to finalize.

If merge was started by git pull, same flow applies.

5. Verify no unresolved markers

bash
git grep -n '<<<<<<<\|=======\|>>>>>>>'

Run tests/build before pushing.

bash
1# example
2npm test
3# or
4pytest

6. Push and communicate

bash
git push

If merge was in a shared branch, notify team members when conflict-heavy integration is done.

Validation and production readiness

A working snippet is only the first step. To make the solution dependable, validate behavior under representative inputs and operating conditions. Build a small test matrix that includes normal cases, boundary values, and malformed data so failure modes are explicit. If the topic involves time, concurrency, or networking, add at least one test that simulates delayed execution and one test that verifies timeout handling. This catches race conditions and environment-specific bugs that rarely appear in local happy-path runs.

Operational clarity matters as much as correctness. Document assumptions near the implementation: runtime version, required dependencies, expected timezone or locale rules, and platform limitations. Ambiguous assumptions are a major source of production incidents because teammates run the same logic under different defaults. Use structured logs around critical branches and external calls so debugging does not require ad hoc reproduction. Logs should include identifiers and concise context, but avoid sensitive payloads.

For recurring jobs or frequently executed code paths, add observability and guardrails. Define simple success metrics, retry boundaries, and explicit rollback or fallback behavior. Silent retries with no upper limit can hide systemic failures and increase downstream impact. Keep a lightweight pre-deploy checklist in source control so changes remain auditable and repeatable across environments.

text
1release_checklist:
2  - tests cover edge cases and failure paths
3  - runtime and dependency versions documented
4  - logs/metrics confirm expected execution path
5  - retries and timeouts are bounded
6  - rollback or fallback plan is defined

Teams that treat these checks as part of the default implementation workflow usually spend less time on incident triage and more time shipping stable improvements.

Common Pitfalls

  • Running git commit before staging all resolved files.
  • Leaving conflict markers in files accidentally.
  • Resolving conflicts without running tests afterward.
  • Using git merge --abort after significant manual conflict work by mistake.
  • Pushing merge results without reviewing combined code behavior.

Summary

Finishing a merge after conflicts is a clear sequence: resolve, stage, commit, verify, push. Use git status as the source of truth and scan for leftover conflict markers before finalizing. With a disciplined workflow, conflict-heavy merges become predictable and low risk.

In collaborative teams, documenting this exact workflow and enforcing it with simple CI or runbook checks prevents repeated mistakes and keeps behavior consistent across development, staging, and production environments.


Course illustration
Course illustration

All Rights Reserved.