Skip to content
intermediate2 min readFree guide

Git branches and merge conflicts: combine intent, not just text

InterviewSolutionHub learning library · Updated

On this page

A branch lets a line of work move independently in history. When two changes overlap, resolving the conflict means deciding the correct combined behaviour and verifying it afterward.

Understand the branch as a reference

A branch name refers to a commit and moves as new commits are added on that branch. It is not a second complete project folder that needs manual copying. Before switching, inspect uncommitted work and make a deliberate choice about how to preserve it. A clean, understood working state makes the next steps easier to reason about.

Read both sides of a conflict

A conflict marker identifies text Git could not combine automatically. Read the surrounding code and the purpose of both changes. Keeping one entire side simply because it compiles can silently discard a needed behaviour from the other side. Ask for context when the correct business rule is not clear.

Verify the combined result

Remove the markers, inspect the diff and run the checks relevant to the resolved behaviour. A merge without textual conflicts can still contain a logical conflict, such as one change calling an interface that another change has renamed. Treat the combined system as the thing to review, not just the marked lines.

Worked example

Imagine one branch renames a price field while another adds validation for that field. A correct merge must preserve the new name and ensure validation still applies. Merely deleting the conflict markers does not establish either requirement.

Check your understanding

Try each question before opening its explanation. These are free practice prompts; they do not use game chances.

Does a branch copy every tracked file into a new directory?

No. It is a reference into the repository history. Git updates the working tree to represent the selected history when you switch appropriately.

Can a conflict-free merge still be wrong?

Yes. Changes can combine textually while disagreeing logically. Run suitable checks and inspect the behaviour affected by both changes.

What should you check after resolving the renamed-field example?

Confirm that reads, writes and validation all use the intended field name, then exercise both valid and invalid input. Check that neither branch’s required behaviour was accidentally discarded.

Sources and further reading

These original examples explain foundational concepts. Use the official references for complete, current details and version-specific behaviour.

About this guide: AI-assisted educational content with original examples and linked primary references. Found an issue? Tell us what to improve.

Keep exploring Developer tools

All subtopics →