Skip to content

Instantly share code, notes, and snippets.

@bnguyensn
Last active February 27, 2021 11:25
Show Gist options
  • Save bnguyensn/f0bbdef59eaa86ead97df9a104aa2fa1 to your computer and use it in GitHub Desktop.
Save bnguyensn/f0bbdef59eaa86ead97df9a104aa2fa1 to your computer and use it in GitHub Desktop.
git tag / npm version

git tag

This gist describes tagging in git

Annotated tags

Create a new annotated tag identified with "v1.0.0":

$ git tag -a v1.0.0

Create a new annotated tag identified with "v1.0.0", along with an inline message:

$ git tag - a v1.0.0 -m "My release message"

Lightweight tags

Create a new lightweight tag:

$ git tag v1.0.0

Sharing tags

By default, git push does not push tags to the remote server. Explicitly push a tag version with git push origin <tag name> or push all tag versions with git push origin --tags.

Other commands

Command Description
git tag List all existing tags
git tag -l 'v1.*.*' List all existing tags matching v1.x.x
git tag -l -n3 List all existing tags along with their contents
git show <tag identifier> Displays details of a tag by its identifier

npm version

Basic

Documentation link: here

Running npm version <update-type> does 2 things:

  • Bump the version field in package.json as specified by <update-type>
  • Create a version commit and tag as controlled by git-tag-version. This behaviour can be disabled with the --no-git-tag-version flag.

A version message can be appended using npm version <update-type> -m "Update to %s for reasons"

Hooks

There are 3 hooks that, if defined in package.json, will be executed as part of running npm version:

  • preversion (runs before npm version)
  • version (runs after the version field is updated)
  • postversion (runs after the version script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment