How do you resolve git conflicts in yarn.lock

Solution 1:

Since Yarn 1.0 it's easy because it has built in support for this scenario.

First solve the conflict in package.json manually, then just run this:

$ yarn install

yarn install v1.0.1
info Merge conflict detected in yarn.lock and successfully merged.
[1/4] Resolving packages...

And then the conflict will be resolved and you can commit that or continue rebasing if that was what you were doing.

Solution 2:

A good approach is detailed in this github discussion about the issue.

git rebase origin/master

When the first conflict arises, I checkout the yarn.lock then re-perform the installation

git checkout origin/master -- yarn.lock 
yarn install

This generates a new yarn.lock based on the origin/master version of yarn.lock, but including the changes I made to my package.json. Then it's just a matter of:

git add yarn.lock
git rebase --continue