Reputation: 83
I've currently configured my repository to use Rubocop for pre-commit linting by creating a pre-commit hook under ./git/hooks
However, I'd like this to be available to everyone working on my team, and hence I'd like to push these changes to Github.
How do I go about pushing the changes related to pre-commit linting onto the remote repository without committing the .git
folder?
Upvotes: 4
Views: 2539
Reputation: 1692
You could use a managed solution for pre-commit hook management like pre-commit. Or a centralized solution for server-side git-hooks like Datree.io. It has built-in policies like:
It won't replace all of your hooks, but it might help your developers with the most obvious ones without the configuration hell of installing the hooks on every developers computer/repo.
Disclaimer: I am one of Datrees founders
Upvotes: 1
Reputation: 17342
I think it's fairly common practice when using git hooks to, for example, check in a hooks/
directory. Then, users can symlink from .git/hooks/foo
to hooks/foo
.
You might even consider putting a shell script in the repository that creates the necessary symlinks when the user runs it. For example, hooks/setup.sh
might run something like ln -s ./foo ../.git/hooks/foo
.
Ultimately, though, each user would still have to take some action to set up his own hooks. (See this question for more info).
Upvotes: 2