Junior — Middle
How can conflicts be resolved when merging branches in a version control system?
sobes.tech AI
Answer from AI
When merging branches in a version control system (e.g., Git), conflicts may occur if changes in different branches affect the same lines in files.
To resolve conflicts:
- Execute the merge command, for example
git merge branch-name. - If a conflict arises, Git will notify you and mark the conflicting sections in the files with special markers:
<<<<<<< HEAD
your code
=======
code from the branch being merged
>>>>>>> branch-name
- Open the files, find these markers, and manually select or combine the necessary changes.
- After fixing conflicts, save the files and execute:
git add <files>
git commit
- If you use GUI tools (e.g., VSCode, GitKraken), they provide visual means for convenient conflict resolution.
Thus, resolving conflicts is the process of choosing the correct code option that combines changes from both branches.