github 中 ^1.0 和 ~1.0 版本的区别

Difference between ^1.0 and ~1.0 version in github

任何人都可以向我解释 ^1.0 和 ~1.0 之间的区别

  "miserenkov/yii2-phone-validator": "^1.0"

   "udokmeci/yii2-phone-validator" : "~1.0"

谢谢

这些就是所谓的“Next Significant Release Operators”。

The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.

.. 而 ^ 稍微更允许:

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0

更新 ~1.2.3 不会升级到 1.2.x 之外的任何其他内容,而 ^1.2.3 可以更新到 1.2.3 之后的任何内容,一直到 [=14] =].

在您的情况下,它们的行为应该相同。

来自文档: https://getcomposer.org/doc/articles/versions.md

Caret Version Range (^)#

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates.
For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.
For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.

Tilde Version Range (~)#

The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.
As you can see it is mostly useful for projects respecting semantic versioning.
A common usage would be to mark the minimum minor version you depend on, like ~1.2 (which allows anything up to, but not including, 2.0).
Since in theory there should be no backwards compatibility breaks until 2.0, that works well.
Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.

在节点"^1.0"总是更新到最后一个版本并且"~ 1.0" 将保留当前版本。

希望对您有所帮助!