bluetoothlover_doc icon indicating copy to clipboard operation
bluetoothlover_doc copied to clipboard

git hook技术

Open chenyingchun0312 opened this issue 1 year ago • 1 comments

  • 默认hooks目录为仓库根目录:.git/hooks/下,但是该目录不能被git仓库管理
  • 如果希望hooks脚本,git clone下来就有,而不需要其他同事自己配置,可以进行如下操作
  • 如果您希望将 Git 钩子脚本放在仓库根目录下的 .hooks 目录中,而不是 .git/hooks 目录中,您可以使用 core.hooksPath 选项来配置 Git。

首先,您需要在终端中进入您的 Git 仓库目录,并使用以下命令设置 core.hooksPath: git config --global core.hooksPath .hooks 这将设置 Git 钩子脚本的路径为仓库根目录下的 .hooks 目录。接下来,您可以将您的自定义钩子脚本放在 .hooks 目录中。

  • 将.hooks放到git仓库管理
  • 其他同事git clone后,只需要执行上面的命令,就可以将hooks目录重新修改为根目录.hooks了
  • 如果期望git clone后执行脚本,可以添加post-checkout脚本
  • 这里其实有一个没有特别说明的,就是这些脚本,必须要有可执行权限

chenyingchun0312 avatar Apr 03 '23 15:04 chenyingchun0312

git add $changed_files

这里如果formatting不执行的话,可能git add没有add上去。 可以在最后git add.

supperthomas avatar May 13 '23 15:05 supperthomas