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 8199825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:15:02+00:00 2026-06-07T06:15:02+00:00

I create a commit-msg hook in myrepo/.git/hooks . #!/bin/sh message=`cat $1` c=`echo $message|grep -c

  • 0

I create a commit-msg hook in myrepo/.git/hooks.

#!/bin/sh
message=`cat $1`
c=`echo $message|grep -c 'fff'`
if[ $c -gt 0 ];then
  echo "Error"
  exit 1
fi
exit 0

When I try to commit like so, an error occurs and it blocks the commit.

$ git commit -m "reffrffffeffff fffeef"
Error

I then do the following:

$ cd myrepo
$ mkdir .hooks
$ mv .git/hooks/commit-msg .hooks/commit-msg
$ ln -s .hooks/commit-msg .git/hooks/commit-msg

and try to commit again with the same message.
The commit succeeds. I guess I may have done something wrong in the above steps?

Can anyone tell me how to make a client-side hook, and have each developer get restrictions from this hook?

  • 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-07T06:15:03+00:00Added an answer on June 7, 2026 at 6:15 am

    The problem in your steps:

    You made a bad symbolic link. The commit-msg symbolic link points to .git/hooks/.hooks/commit-msg. Instead, try this:

    $ cd myrepo
    $ mkdir .hooks
    $ cd .git/hooks
    $ mv commit-msg ../../.hooks/commit-msg
    $ ln -s !$ commit-msg  # lazy: '!$' expands to '../../.hooks/commit-msg'
    

    How to restrict each developer’s commit message

    As you know, the commit-msg hook is a client-side hook. If you want each developer’s commit messages to be rejected if they don’t follow some scheme, you need to have the developers install the hook themselves. You can’t maintain hooks as part of your repository, but keeping them in another Git repo is an option. (To be clear, you could keep them in your repository, but your developers would still need to make symlinks in the .git/hooks directory, as you have).

    If you truly want to force developers to be restricted by a hook, look into server-side hooks. You could use pre-receive, for example, to check that all pushed commit messages obey your scheme.

    Chapter 8.3 (Customizing Git – Git Hooks) of Pro Git is an excellent resource. There are some quality walk-throughs there to help you. You can also take a look at the example files included in .git/hooks for your repository.

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

Sidebar

Related Questions

We have a nice pre-commit hook for GIT, as well as a nice commit-msg.
I get the following error: ActiveRecord::AssociationTypeMismatch in ContractsController#create ExchangeRate(#2183081860) expected, got HashWithIndifferentAccess(#2159586480) Params: {commit=>Create,
If I create a commit with git stash create whatever I get a hash
Is it possible to create a commit message with link to other repository commit?
In my project master branch I commit changes: git commit -a create & switch
Currently, when I run git svn dcommit git creates a separate commit in SVN
I am discovering how to use git. I just made the following test: create
After invoking git merge --no-commit <commit> , performing a commit will result in a
In some settings, I am used to using git locally, and then exporting a
Here's the situation. I'm working on the master branch. I create file1 and commit.

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.