Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8090279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:40:02+00:00 2026-06-05T19:40:02+00:00

I want to add a commit hook that works when a push is received

  • 0

I want to add a commit hook that works when a push is received on a gitolite/git server for a given branch and repo combination only (branch ‘cat’ on repo ‘dog’).

My environment:
git version 1.7.4.1,

What I have done so far:

  1. Touched a file at /home/git/repositories/dog.git/hooks/post-receive.secondary on the git/gitolite server.

  2. Edited the file with the contents:

    #!/bin/sh
    #
    refname="$1"
    oldrev="$2"
    newrev="$3"
    if [ "$refname" == "refs/heads/cat" ]
    then
       touch /tmp/test
    fi
    
  3. Set the owner of the file to the ‘git’ user

  4. Set the file permissions to 700

  5. Done a commit to “cat” branch of “dog” repo

Results:
the test file is not created

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:40:03+00:00Added an answer on June 5, 2026 at 7:40 pm

    If I look at Gitolite v2 (g2) hook chaining section, only two hooks are concerned with the “.secondary” extension:

    • The update hook, because it is used in all repos and is critical to gitolite’s access control
    • The post-update hook, because it is used in the gitolite-admin repo only, to “compile” the configuration and so on.

    • (post-receive is only involved if mirroring is activated, which shouldn’t be the case in your gitolite installation)

    So you shouldn’t need to declare a post-receive.secondary, just a post-receive hook in your </path/to/gitolite>/hooks/common/, as described in “How to install hooks in gitolite“.


    The OP specialsauce concludes in the comments:

    I needed a post-receive hook in the repository folder (Rather than a secondary one) , which I think was the main reason that it wasn’t executing.

    The only other thing I changed in the end I believe was setting the perms from 700 (which should have been fine anyway?) to 755.
    The hook now executes reliably.

    I did not need to run the gl-setup script. Additionally I changed from the var assignment code as outlined above to a “while” on STDIN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to add an update hook to git that prevents people from
I would like to add an update hook to git that prevents people from
I have a file in folder/anotherFolder/file.php I want to add, commit and push, what
I have a list of string values that I want add to a hashtable
I want to add a splashscreen within an App that is an iPad-App currently.
Using this hook with VisualSVN Server, added to the Repository/hooks folder as pre-commit.bat. My
I currently have a pre-commit hook in my mercurial project that gives the user
We have a nice pre-commit hook for GIT, as well as a nice commit-msg.
So, basically, I've got a load of code that I want to add to
On git-filter-branch , it is said: To set a commit (which typically is at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.