my-git

Resolve Conflicts

English 中文

The key to resolving conflicts is to first understand the intent of both sides, then decide which side to keep or how to merge.

Do not mechanically choose ours or theirs just because you see conflict markers.

What a Conflict Looks Like

  <<<<<<< HEAD
Current branch content
  =======
Merged branch content
  >>>>>>> feature/login

You need to organize this content into the final desired state and delete the conflict markers.

Conflicts During Merge

Check status:

git status
git diff

After resolving files:

git add <resolved-files>
git merge --continue

If things go wrong:

git merge --abort

Conflicts During Rebase

Check status:

git status
git diff

After resolving files:

git add <resolved-files>
git rebase --continue

If things go wrong:

git rebase --abort

Handling Advice

Check conflict sources:

git log --oneline --left-right --merge

AI Programming Scenarios

AI is prone to just doing text splicing when handling conflicts.

Have AI explain the semantics of both sides, then let a human confirm the final result.

Further Reading