有没有办法在'git add'命令之前/之后运行git hook?

时间:2017-05-23 16:14:07

标签: git automation githooks

我检查了git help hooks,这是不可能的,或者我错过了这个。

我希望这个而不是pre-commit作为存储库中的程序生成文件,因此我当前的工作流程是

git add -A ruby script_stored_in_repository_that_generates_something.rb <checking generated work that is not tracked in the repository> git commit -m "what was changed"

我希望消除手动脚本运行无意义。

我知道我可以使用pre-commit挂钩,但我更喜欢在代码暂停时编辑工作,而不是恢复/撤消/修改提交。

1 个答案:

答案 0 :(得分:1)

不幸的是,我不认为存在。我认为你最接近的就是做一个别名。您不能使用别名覆盖git命令,因此您必须使用与“添加”不同的名称。

git config alias.ad '!./my_script.sh && git add'