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'
On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit. You can add a co-author by adding a trailer to the commit.
Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message"
The easiest way to create a Git commit with a message is to execute “git commit” with the “-m” option followed by your commit message.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With