# The Composer merge conflicts dilemma

> In this article, I will share some of the methods that you may be used to resolve composer.lockgit merge conflict. By following these methods, you can save yourself from the same headache and make your life a bit easier.

Source: https://antistatique.net/en/blog/the-composer-merge-conflicts-dilemma

Category: Development

# The Composer merge conflicts dilemma

Author(s)

[

![Kevin](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2020/12/Kevin-300x300.jpg)



](/en/agence/kevin)

[Kevin](/en/agence/kevin)17 April 2023

If you have stumbled upon this page, it’s likely that you are all too familiar with the nasty composer.lock git conflict.

The message you read and know you’r f\*cked’up

You know, that frustrating and time-consuming problem that can drive you crazy, may lose others developers works such as added, removed or updated packages and leave you feeling like you’re stuck in a never-ending game of whack-a-mole.

Merging Git conflicts, what a lovely task to do

In this article, I will share some of the methods that you may be used to resolve `composer.lock`git merge conflict.  
By following these methods, you can save yourself from the same headache and make your life a bit easier.

## The Prohibited Protocol

I’ve seen some developers try to tackle `composer.lock` merge conflicts in some very interesting ways.

The best solution to handle merge-conflict, is to delegate

For instance, some have used `git checkout --ours composer.lock` and then pushed those changes directly to the branch.  
While this might seem like a quick fix, it actually overwrites all the other developers’ changes with yours. Essentially, **it’s like force-pushing your changes — a big no-no!**

Another commonly considered option (though not a good one) is to delete the `composer.lock` file and create a new one with `composer update`.   
While this might seem like a viable solution if you’re feeling adventurous and don’t really care about the locked versions, it’s important to keep in mind that this approach can result in **unforeseen changes to your feature branch and generate unnecessary diffs**.

## Method N°1: The Content Conundrum

Whenever I see a merge conflict in my `composer.lock`, it’s usually because of that pesky little `content-hash`. This key is a unique fingerprint for all the dependencies.

Example of merge conflict into composer.lock on the content-hash key

When I spot that the only conflict is with the `content-hash`, I know it’s an easy fix.

In this case, all you have to do is:

1.  Delete all the Git confusion (the `HEAD`, `==` and `<<` chars)
2.  Pick one of the two `content-hash` values — it doesn’t matter which
3.  Run this magic command

```
composer update - lock
```

Problem **solved**!

## Method N°2: The Revision Reverberation

Sometimes `composer.lock` can get so messy and confusing with a gazillion changes, versions, and hash updates.

When I find myself in this sticky situation, I’ve found that it’s better to start fresh by adding or removing the packages on top of the latest changes from the source branch.

It’s like giving your `composer.lock` a fresh makeover, and it’s so much better than trying to play Sherlock Holmes and figure out the tangled mess of changes!

1.  First, accept the changes from base (`main`) branch:

```
git checkout --theirs composer.lock composer.json
```

2.  Then, re-play all the packages you added, updated or removed in your feature branch:

```
composer require package/a:^1.2
composer require package/b:^2.0
composer remove package/c
composer require --dev package/d
composer update package/x
```

When you’re done, make sure your `composer.json` and `composer.lock` files are valid using `composer validate` command.

Problem **solved**!

## Method N°3: The Composer Convergence

If you want to keep those locked versions intact and avoid a whole lot of extra diff drama, you can use an external tool like the [Composer Git Merge Driver](https://github.com/balbuf/composer-git-merge-driver).

This bad boy automates the merge process and makes sure everything stays organized and in its place. Check out the [official repository](https://github.com/balbuf/composer-git-merge-driver) for all the juicy installation and usage deets.

## Sources

**Ion Bazan** (Apr, 2021) Efficiently resolving composer.lock merge conflicts.  
[https://dev.to/ionbazan/efficiently-resolving-composer-lock-merge-conflicts-1peb](https://dev.to/ionbazan/efficiently-resolving-composer-lock-merge-conflicts-1peb)

**Mike Madison**(Aug, 2020) Resolving composer.lock git merge conflicts.  
[https://mikemadison.net/blog/2020/8/18/resolving-composerlock-git-merge-conflicts](https://mikemadison.net/blog/2020/8/18/resolving-composerlock-git-merge-conflicts)

**ChatGPT** (2023)  
[https://chat.openapi.com](https://chat.openapi.com/)

**Midjourney** (2023)  
[https://midjourney.com](https://www.youtube.com/watch?v=5JoEB2YTlpw)

## More articles

Author(s)

[

![Anthony](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2024/11/anthony-1-300x300.png)



](/en/agence/anthony-salamone)

[Anthony](/en/agence/anthony-salamone)28 September 2026

### [Smashing Conference Freiburg 2026](/en/blog/smashing-conference-freiburg-2026)

Back in Freiburg for Smashing Conference 2026: AI and design systems, deeply technical CSS and HTML, and more human talks about teams and mindset. Here's what we took away.

Back in Freiburg for Smashing Conference 2026: AI and design systems, deeply technical CSS and HTML, and more human talks about teams and mindset. Here's what we took away.

[

![Smashing Conference Freiburg 2026 poster](https://images.statique.ch/t/w_750,h_500,c_fill,f_jpeg,q_70/assets/blog/smashing-2026.png)



](/en/blog/smashing-conference-freiburg-2026)

Author(s)

[

![Akira](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2025/03/akira-small-300x300.jpg)



](/en/agence/akira-kamata)

[Akira](/en/agence/akira-kamata)22 July 2026

### [Making of : “La nuit des Losers”](/en/blog/making-of-la-nuit-des-losers)

lanuitdeslosers.ch, built fast: paper wireframes, a bold hand-drawn identity, then Claude Code to prototype and ship. A mouse-tracking hero animation, a bowling game made of sponsor logos, and a few bugs we’re keeping.

lanuitdeslosers.ch, built fast: paper wireframes, a bold hand-drawn identity, then Claude Code to prototype and ship. A mouse-tracking hero animation, a bowling game made of sponsor logos, and a few bugs we’re keeping.

[

![Making of : “La nuit des Losers”](https://images.statique.ch/t/w_750,h_500,c_fill,f_jpeg,q_70/wp/app/uploads/2026/05/La-nuit-des-Losers-Teaser-1-768x576.png)



](/en/blog/making-of-la-nuit-des-losers)

Author(s)

[

![Pierre](https://images.statique.ch/t/w_750,h_750,c_fill,f_jpeg,q_70/wp/app/uploads/2020/12/Pierre-300x300.jpg)



](/en/agence/pierre)

[Pierre](/en/agence/pierre)7 July 2026

### [Dark mode: necessity or trend](/en/blog/dark-mode-necessity-or-trend)

Nous faisons le tri entre idées reçues, réalités techniques et bonnes pratiques de design.

Nous faisons le tri entre idées reçues, réalités techniques et bonnes pratiques de design.

[

![Dark mode: necessity or trend](https://images.statique.ch/t/w_750,h_500,c_fill,f_jpeg,q_70/wp/app/uploads/2026/07/1-768x384.png)



](/en/blog/dark-mode-necessity-or-trend)
