Git Merge Conflict Resolution And Learning Resource

2024-11-22
Git
Git merge
version control
development tools

Merge conflicts

When merging branches in Git repository, conflicts sometimes emerge. There's certainly a way to solve them manually, but sometimes they're too large and don't actually matter (like e.g. yaml-lock in a Node project), and sometimes they should be resolved by picking everything from either branch.

There's a way to use specific merge strategy to resolve everything either way:

git merge --no-ff -X theirs branchname

or

git merge --no-ff -X ours branchname

But sometimes it's not that trivial - sometimes some changes need to be resolved one way, and some the other. In that case, when merge encountered conflicts, it's done like so:

git checkout --theirs [path/file]

or

git checkout --ours [path/file]

(also, git add [path/file] still required afterwards to mark resolution)

Learning resource

There's a great resource that explains these - and much more, like what's --no-ff - in great details: https://craftquest.io/guides/git/git-workflow-tools/git-merge