merging package.json in git (solving version confl

2020-07-18 22:59发布

问题:

We keep getting a conflict for the version field in the package.json. For instance:

"version": "1.1.144"

and:

"version": "1.1.145"

Is there a way to auto-resolve it with the highest version number?

回答1:

Ended up writing an npm package that checks for the version in the remote and sets the local version to match.

npm install -g node-version-match

and from a project's directory:

level

This will sets the local package.json version to match the remote package.json version:

{
  "name": "package",
  "version": "0.0.152", // <=== sets this to equal the version in remote
 ...

This prevents conflicts before pulling, afterwards we change the version number, commit & push.