Software Development and Project Management
In Git, two developers changed the same line of the same file on different branches, and one branch was then merged into the other. Which describes what happens?
- AThe change with the newer commit time is adopted automatically, and the older change is discarded
- BThe changes on the receiving branch always take priority, and the other branch's changes are discarded automatically
- CThe merge stops with a conflict, and a developer examines the content and resolves it by deciding which change to keep (or how to combine both)
Show answer and explanation
Answer: C. The merge stops with a conflict, and a developer examines the content and resolves it by deciding which change to keep (or how to combine both)
A Git merge compares the changes on both branches since their common ancestor and combines changes in different places automatically. If the same place was changed on both sides, it cannot be decided mechanically which is correct, so the merge stops with a conflict and both versions are marked in the file. The developer edits the file to resolve it, tests, and then commits. Merging often rather than keeping branches apart for a long time is an effective way to reduce conflicts.
- A. Git does not choose changes by time. Changes to the same place are resolved by a person.
- B. A standard merge does not automatically discard either side's changes; it stops with a conflict.
- C. Correct. Changes to the same place become a conflict, which a person resolves.
Continue: 9 more Software Development and Project Management questions