linux - 创建一个 git post-push 钩子
问题描述
我正在尝试为 git 创建一个推送后挂钩。目标只是在将代码推送到 Github 后运行 shell 命令来启动 gitrob。我发现了这个:https ://stackoverflow.com/a/3812238/9709330 但我是一个菜鸟 Linux 用户,当我将我的 post-push 挂钩保存为 /usr/local/bin 中的“git-push-wh”时(它在我的 $PATH 中),它没有改变任何东西,当我运行 git push-w 时它无法识别。
有什么帮助吗?或任何其他方式来做到这一点?谢谢 :)
解决方案
一种想法是将函数添加到您的~/.bashrc
或~/.zshrc
您的 shell 可以访问该函数的方式中,您可以简单地通过函数名称调用 shell 中的函数。在将函数添加到这些文件中的任何一个之后,您还需要告诉您的 shell 进行更新,source ~/.bashrc
这样就可以了。
我的例子~/.bashrc
:
function test() {
echo "yo"
}
然后我source ~/.bashrc
在我的 shell 中运行 and now:
bash-3.2$ test
yo
我希望这有帮助!
推荐阅读
- python - Scrapy - Python - 在 div 中使用 p 抓取所有文本
- go - 如何借助 Golang 中的标志使用随机参数
- java - 字符串修剪异常
- javascript - Youtube 视频不是在 Electron 应用程序中播放,而是在网站中播放
- excel - Value2 数字作为字符串
- javascript - 为什么 .push() 方法会重复它添加到数组中的最后一个元素的值?
- php - Laravel:雄辩和多列索引
- kubernetes - 无法访问 Kubernetes Windows 节点上 Pod 中的服务
- ruby-on-rails - 为什么部署后 Heroku 请求时间变慢/变快
- html - 子元素裁剪父元素?