Git hooks management

前端 未结 6 821
梦毁少年i
梦毁少年i 2020-12-14 02:22

We use custom-written Git hooks in our project.

Hooks are stored in a project\'s repository, and, when they do change, to get a new version each user must copy them

相关标签:
6条回答
  • 2020-12-14 02:24

    We made .git/hooks a symlink into the working tree.

    For those rare occasions when someone needs to commit files that the hooks will reject, we use git commit --no-verify

    0 讨论(0)
  • 2020-12-14 02:26

    In Git 2.9, you can point to a custom hooks directory using the core.hooksPath configuration.

    Git 2.9 Release Notes - https://github.com/blog/2188-git-2-9-has-been-released

    Documentation mentioning core.hooksPath - https://git-scm.com/docs/githooks

    Note - this question is a possible duplicate of Can Git hook scripts be managed along with the repository?

    0 讨论(0)
  • 2020-12-14 02:31

    For NodeJS-based projects, I suggest you taking a look at ghooks.

    0 讨论(0)
  • 2020-12-14 02:40

    http://benjamin-meyer.blogspot.com/2010/06/managing-project-user-and-global-git.html appears to be a convenient way to automate hook symlinking, to facilitate global, per user, and per project hooks.

    0 讨论(0)
  • 2020-12-14 02:44

    You could make the repository's .git directory a git repository, and just add hooks and other config to it, adding the objects, refs, etc. directories and files like index to its .gitignore. Not only that, but you could set up a post-receive hook to update the metarepo from its origin. Once you had the initial configuration set up, you could have it pull in updates without any additional effort.

    I'm working out the details of this, like what should go in the ignore list; I'm keeping the results in branches of this repo.

    0 讨论(0)
  • 2020-12-14 02:50

    Maintain a separate repository of your hooks and symlink into that.

    I agree, it'd be nice if Git had a built-in mechanism for propagating hooks scripts but it doesn't.

    0 讨论(0)
提交回复
热议问题