What is caret (^) and tild(~) in version control

~ Tilde:

  • ~ freezes major and minor numbers.
  • It is used when you’re ready to accept bug-fixes in your dependency, but don’t want any potentially incompatible changes.
  • The tilde matches the most recent minor version (the middle number).
  • ~1.2.3 will match all 1.2.x versions, but it will miss 1.3.0.
  • Tilde (~) gives you bug fix releases

^ Caret:

  • ^ freezes the major number only.
  • It is used when you’re closely watching your dependencies and are ready to quickly change your code if minor release will be incompatible.
  • It will update you to the most recent major version (the first number).
  • ^1.2.3 will match any 1.x.x release including 1.3.0, but it will hold off on 2.0.0.
  • Caret (^) gives you backwards-compatible new functionality as well.
ValueDescription
~version“Approximately equivalent to version”

For example:
~1.1.5: 1.1.0 <= accepted < 1.2.0

Pattern:
~ is 1.2.[any] (latest patch)
^version“Compatible with version”

For example:
^1.1.5: 1.1.5 <= accepted < 2.0.0
^0.1.3: 0.1.3 <= accepted < 0.2.0
^0.0.4: 0.0.4 <= accepted < 0.1.0

Pattern:
^ is 1.[any].[any] (latest minor version)
versionMust match version exactly
>versionMust be greater than version
>=versionetc
<version
<=version
1.2.x1.2.0, 1.2.1, etc., but not 1.3.0
*Matches any version
latestObtains latest release