在版本控制上更新pre_commit钩子文件 [英] Update pre_commit hook file on version control
问题描述
我最近更新了我的 pre_commit.sample
文件,以便在提交时重新运行rubocop(重命名为pre_commit)。
I recently updated my pre_commit.sample
file to run rubocop upon a commit (renamed to pre_commit).
#!/bin/sh
#
# Check for ruby style errors
rake run:rubocop
Mistakingly I thought this would update on other developers machines when pulling the changes. How can i ensure that anyone who pulls the change has their pre_commit file updated
错误地认为这将在更改其他开发人员计算机时更新。我如何确保任何拉取变更的人都已更新其pre_commit文件
Thanks
谢谢
推荐答案
正如我在 Git commit hooks - global settings 和更改默认git钩子去年5月,Git 2.9和2.10引入了 git config core.hooksPath
。
That seems to confuse the OP:
这似乎是混淆OP :
如果我有一个现有的仓库并希望其他所有将更改有一个更新的预先提交钩例如我会怎么做?
在回购中有/。git / hooks / pre_commit
,我可以指向它
更确切地说,在一个git仓库中,有一个 /。git / ho oks / pre-commit.sample
,并且考虑到您需要为所有开发人员提供一个通用的 pre-commit
钩子,您应不 制作,然后指向本地仓库中的 /。git / hooks / pre_commit
脚本。
All developers have to reference the same gobal shared network-accessible path used with git config core.hooksPath \\a\common\shared\path
: that setting needs to be activated on each developer workstation, either within their repo (local setting) or for all their repo (global setting: git config --global core.hooksPath \\a\common\shared\path
.
所有开发人员必须引用与相同的gobal共享网络可访问路径git config core.hooksPath \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ $ c>:该设置需要在每个开发人员工作站上激活,无论是在其repo(本地设置)还是其所有repo(全局设置:
git config --global core.hooksPath \\ a \common\shared\path
。
(I use here a Windows UNC syntax, use the one suited for your OS)
(我在这里使用 Windows UNC语法,使用适合您的操作系统的语法)
所有引用相同的路径,你可以设置你的pre-commit钩子那里:
Once they all reference the same path, you can set up your pre-commit hook there:
\\a\common\shared\path\pre-commit
然后您可以更新该脚本(每个人都可以访问),允许所有开发人员立即获得更新。
Then you can update that script (the one accessed by everyone), allowing all developers to benefit instantly of the updates.
这篇关于在版本控制上更新pre_commit钩子文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!