【问题标题】:How to push to github with custom commit message with npm scripts?如何使用 npm 脚本使用自定义提交消息推送到 github?
【发布时间】:2017-11-11 14:07:35
【问题描述】:

在我的package.json 我有这个

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

在终端中我运行npm run git 并推送更改。但是我怎样才能即时更改提交消息呢?例如npm run git MESSAGE='another commit'

【问题讨论】:

  • 需要修改package.json中的命令为git commit -m 'some message'。

标签: node.js git npm npm-scripts


【解决方案1】:

涉及一些 npm 技巧的解决方案可能包括:

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

被称为:

npm run git -- "Message of the commit"

或:

npm run git -- Message

【讨论】:

  • 只是提一下,postgit 使用了一个 post 钩子,并且总是在 git 脚本执行后被调用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 2020-01-04
  • 1970-01-01
  • 2016-01-10
  • 2012-08-01
相关资源
最近更新 更多