15

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
  • you need to modify the command in package.json to git commit -m 'some message'. Commented Jun 9, 2017 at 14:11

1 Answer 1

26

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
Sign up to request clarification or add additional context in comments.

1 Comment

just to mention that postgit uses a post hook and is always called after the execution of git script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.