Logan Bailey

Adventures In Web Development

Blog, About, GitHub, and LinkedIn

When using composer in large groups, your composer.lock file will often be the source of merge conflicts. This can happen for a multiple reasons, but generally it happens when the branch you're merging in has updated to a different version of the same library. I used solved this issue was by deleting my lock file and running composer update. As long as everything was setup right, what could go wrong?

The other day I came across a better solution.

git checkout --theirs composer.lock

During merges git offers --theirs and --ours flags to checkout command. These flags allow you retain the file changes for either the branch being merged --theirs or to retain your changes --ours.

I use the --theirs flag to "reset" the lock file to the state of the branch being merged in. I run composer update vendor/package for the packages that I know I updated.

Posted In: