简体   繁体   English

在git checkout / pull上触发rsync

[英]Trigger rsync on git checkout/pull

My question may be naive but I can't figure it out... 我的问题可能很幼稚,但我无法解决...

Can I trigger an rsync or more generally a custom script, on a local repository when git commands are executed ? 执行git命令时,是否可以在本地存储库上触发rsync或更一般的自定义脚本? I tried looking into hooks but I'm not quite sure if these are supposed to/can be used in this case. 我尝试研究挂钩,但不确定在这种情况下是否应该/可以使用它们。

I also thought I should simply use git aliases to do these, but I am not sure what is dumb, stupid or idiot among my ideas. 我还认为我应该只使用git别名来执行这些操作,但是我不确定我的想法中有什么愚蠢,愚蠢或白痴。

I would say git hooks are the best way to solve that task, because they were introduced for doing stuff like that: 我会说git hooks是解决该任务的最佳方法,因为引入它们是为了实现以下目的:

"Hooks are little scripts you can place in $GIT_DIR/hooks directory to trigger action at certain points." “钩子是一些小脚本,可以将它们放在$ GIT_DIR / hooks目录中,以在某些时候触发操作。” - from man githooks -来自man githooks

Also, if you - or anybody else - would like to change the git post-commit -behaviour, i'd bet he'll have a first look into the $GIT_DIR/hooks/ -directory. 另外,如果您-或其他人-要更改git post-commit commit-行为,我敢打赌,他将首先查看$GIT_DIR/hooks/

But be aware that 3rd-party tools (like GUIs) may use an internal git implementation (like JGIT) which may unfortunately not call hooks! 但是请注意,第三方工具(如GUI)可能会使用内部git实现(如JGIT),不幸的是,它可能不会调用钩子!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM