9

I would like to use pre-commit hook in gitlab. I doing everything like in documentation: https://docs.gitlab.com/ce/administration/custom_hooks.html

In custom_hooks directory I've created pre-commit file with folowing content:

#!/bin/bash

exit 1

Hook is never triggered, couse i can commit.

When i do the same with pre-receive hook - everything works good.

If Gitlab doesnt't let to use pre-commit hook?

1
  • 2
    Solved - pre-commit is a client-side hook and should be stored in .git/hooks location on client machine (in my case on Windows). It’s important to note that client-side hooks are not copied when you clone a repository. I will try do everything using server-side hooks. Commented Sep 30, 2016 at 8:46

1 Answer 1

8

As explained in Customizing Git - Git Hooks, a client-side hook won't be used on the server.

I explained before why it is not possible to include hooks in a clone:

Since GitLab 7.5, you can set custom Git Hooks for server-side hooks.

Git natively supports hooks that are executed on different actions. Examples of server-side git hooks include pre-receive, post-receive, and update

Normally, Git hooks are placed in the repository or project's hooks directory. GitLab creates a symlink from each project's hooks directory to the gitlab-shell hooks directory for ease of maintenance between gitlab-shell upgrades

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.