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

时间:2017-10-26 12:03:07

标签: github version-control version

任何机构都可以解释^ 1.0和~1.0之间的区别

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

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

由于

3 个答案:

答案 0 :(得分:3)

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

  

〜运算符最好用例子解释:~1.2相当于&gt; = 1.2 <2.0.0,而~1.2.3相当于&gt; = 1.2.3 <1.3.0。

..而^稍微允许:

  

^运算符的行为非常相似,但它更接近语义版本控制,并且总是允许不间断的更新。例如,^ 1.2.3等同于> = 1.2.3 <2.0.0

更新~1.2.3不会升级为1.2.x以外的任何内容,而^1.2.3可以更新为1.2.3以外的任何内容,一直到2.0.0

在你的情况下,他们的行为应该相同。

答案 1 :(得分:0)

来自文档: 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.

答案 2 :(得分:0)

节点 &#34; ^ 1.0&#34; 中的

始终更新到上一版本, &#34; ~1.0&# 34; 将保留当前版本。

希望这有帮助!