I am trying to resolve a git conflict.
Let's say I have a file versions.json which is already existing in the repo:
{
"a": {
"name": "component-a",
"version": 1,
},
"b": {
"name": "component-b",
"version": 1,
},
}
Then,
- there is a CI pipeline with parallel stages. One building "component-a", the second building "component-b", both being in a monorepo.
- When "component-a" completes, it updates the file and sets
"version": 2in "a" - When "component-b" completes, it updates the file and sets
"version": 2in "b" - Each component will
- Do the changes
- commit the changes
- do a
git pull --rebase - do a
git push
This fails with a merge conflict:
Rebasing (1/2)
Auto-merging versions.json
CONFLICT (add/add): Merge conflict in versions.json
error: could not apply 29b568d2... <previous commit message>
Components will never change the same line, so there is no real conflict IMO.
I tried to add a pull BEFORE the commit which works most of the time, but as the monorepo is quite big it takes time and some time which results in a race condition where one component commits during the pull of the other.
So I would like to fix it on the final push or pull directly.
Is there a way to do this in an automated fashion without human interaction?
"a"and"b"? That way they wouldn't be adjacent.