Handling merge conflicts
How to prevent and resolve merge conflicts
Introduction
Merge conflicts can occur when the i18n.lock file differs between branches. This typically happens when translations are updated independently in different branches.
This page provides some options for preventing and resolving merge conflicts.
Option 1: Commit translations directly to the main branch
One of the available workflows is to generate translations when changes are merged into the main branch and automatically commit those changes directly back to the branch. This workflow prevents merge conflicts because there is no merging happening in the first place.
To learn more, see Choosing a workflow.
Option 2: Merge with lockfile regeneration
When merging branches that have conflicting i18n.lock files, you can resolve the conflict by removing the lockfile and regenerating it after the merge is complete.
-
Start the merge:
git merge <branch-name> -
Delete the conflicting file:
rm i18n.lock -
Stage the changes:
git add . -
Merge the changes:
git merge --continue -
Regenerate the
i18n.lockfile:npx lingo.dev lockfile --forceNote: This command will not trigger the translation of content.
Option 3: Rebase with lockfile regeneration
Similar to merging, when rebasing branches with conflicting i18n.lock files, you can resolve conflicts by removing and regenerating the lockfile.
-
Start the rebase:
git rebase <branch-name> -
Delete the conflicting file:
rm i18n.lock -
Stage the changes:
git add . -
Continue the rebase:
git rebase --continue -
Regenerate the
i18n.lockfile:npx lingo.dev lockfile --forceNote: This command will not trigger the translation of content.