I'm a little hazy on how npm version
works. The documentation says:
If run in a git repo, it will also create a version commit and tag.
Does that mean I don't have to run git commit
or git tag
or does it just take the place of git tag -a <version>
? If I did something like this would I be creating a double commit?
git add . -A
git commit -m "<commit message>"
git push origin master
npm version <patch|minor|major> -m "<version description>" ## instead of git tag -a <version> ##
git push --tags
Your understanding is mostly correct
When you execute the npm version
command the following is done:
package.json
package.json
with the message specified when invoking npm version
.You can then execute npm publish
to publish to the npm registry, and git push your tag to your remote repository when you see fit
As for the exact commands that our executed as you expressed interest in this via comments:
adding the files to staging:
git add /path/to/package.json
If lock and shrinkwrap package files are also present they are also added as above!
creation of the commit:
git commit -m {version message}
as for creation of the tag:
git tag {version no.} -am {version message}
or if signing is turned on:
git tag {version no.} -sm {version message}
For reference the version message
is optional, if it is excluded from the CLI input then it will default to have the value of version no.
.