简体   繁体   中英

How to push to github with custom commit message with npm scripts?

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'

A solution involving some npm trickery might consist of:

"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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM