Reputation:
I have a npm project with a git repository in the same project environment.
With git I do an version upgrade with commits and tags:
$ git commit -m 'my recent repo changes'
$ git tag v1.0.1
With npm I can bump my package version with:
$ npm version patch -m 'my recent repo changes'
But if I try this with changed files, npm throws an error: git working directory is not clean. In the end I need to add and commit my changes with git, but the npm package version is still the same.
Is it possible to synchronize the versions of the npm project inside of my git repo? What is the best practice?
Upvotes: 10
Views: 2349
Reputation: 38106
You do need to keep git repo working directory clean before bumping the package.json
version.
And it's also unnecessary to update the version in package.json
file and add tag manually.
The workflow should be:
Make changes for your project
You can modify your project and it's unnecessary to update the version in package.json
manually.
Commit changes
After modification, commit the changes you made by git commit -am 'message'
.
Bump the version
Then bump the version automatically by npm version patch -m 'message'
. And it will create a new commit for the changes of package.json
version, and add the tag with the new version at the same time.
You can double check for the new commit by showing the commit history (such as use the command gitk --all
).
Upvotes: 4