How to push to github with custom commit message w

2019-06-22 15:49发布

问题:

In my package.json I have this

  "scripts": {
    "start": "gulp serve",
    "git": "git add . && git commit -m 'some-message' && git push --all"
  },

In the terminal I run npm run git and the changes are pushed. But how can I change the commit message on the fly? For example npm run git MESSAGE='another commit'

回答1:

A solution involving some npm trickery might consist in:

"scripts": {
  "git": "git add . && git commit -m",
  "postgit": "git push --all"
},

To be called like:

npm run git -- "Message of the commit"

or:

npm run git -- Message