What methods of conflict resolution can you name when working with Git version control system?
sobes.tech AI
Answer from AI
When working with Git, conflicts arise when changes in the same part of a file are made in different branches. The main methods of resolving conflicts:
-
Manual resolution: open the conflicting file, find the conflict sections (marked with
<<<<<<<,=======,>>>>>>>) and manually choose or merge the changes. -
Using merge tools: special programs (e.g.,
kdiff3,Meld, built into IDEs) that visually show differences and help merge changes. -
Rebasing: sometimes helps avoid conflicts by applying changes on top of another branch, but when conflicts occur, manual resolution is required.
-
Undo changes: if the conflict is too complex, you can cancel local changes and retry the merge after additional analysis.
-
Team communication: coordinating changes and frequent commits help minimize conflicts.
Example of manual resolution:
# After git merge, a conflict occurs
# Open the conflicting file
# Resolve the conflict manually
# Add the resolved file
git add conflicted_file
# Complete the merge
git commit