Git post-windows 上的结帐挂钩

Git post-checkout hook on windows

我在 windows 上安装了 git 2.28.0。 事实上,我在 /.git 库下的钩子库中找不到 post-checkout.sample 钩子。 windows 是否支持 post-checkout.sample 挂钩? 当我在 linux 上安装相同版本的 git 时,我发现了 post-checkout.sample 挂钩。 我什至尝试使用 git 2.23.0 版本,但我遇到了同样的问题。

我尝试创建 post-checkout 来打印一条简单的消息“你好”。但它不起作用。但是,当我在 pre-commit 中复制此文件时,它起作用了。 有什么建议吗?

我从未在 Git For Windows distributionmingw64/share/git-core/templates/hooks/ 中看到 post-checkout.sample

但是那个钩子应该可以工作,只要你做到了:

  • 一个名为“post-checkout”的文件
  • 一个bash脚本(见一个
  • 在您的 repo/.git/hooks 文件夹中

其实有一个proposal (RFC) for a post-checkout.sample in 2009,只是当时没有捡到

问题was asked (also in 2009)

I also noticed that the post-checkout sample does not exist when I init a new archive. Is this a bug?

不,是安全。
钩子是可执行文件,不应该盲目 出于安全原因复制。

它似乎不适用于空存储库。 我刚刚在我的存储库中提交了一个文件,当我执行 git checkout -b new_branch 时,post-checkout 挂钩起作用了。