how to place permanent hooks in .git file

hi ,

    i want to edit the .git folder inside the selected repo and i also want to push it to remote.

is it possible to do , if so plz help me to solve the issue.


Thanks & Regards

Shruti Muktedar

3 answers

1 accepted

This widget could not be displayed.

Hi Shruti,

Balazs is right, you cannot automatically install client-side hooks for all users this way. But you may consider server-side hooks, especially update and pre-receive. See this documentation: 

The downside is that your users might only realize that many of their commit messages are invalid when they try to push, and cleaning up dozens of messages might be a tedious task.

I recommend you to use a server-side (update or pre-receive) hook and an optional client-side pre-commit hook. Your users will happily install the client hook themselves manually if they want their lives become easier smile


Update: Our company (Midori) has released a JIRA plugin called Commit Policy Plugin for JIRA that makes managing centralized source code policies a breeze and it can help in the situation being discussed in this topic.

It allows you to build complex commit rules on the JIRA server via a nice UI and it also allows you to generate ready-to-use hook scripts utilizing these policies for Git (and also currently Mercurial and SVN) in a few mouse clicks. You can simply drop the generated hook script package into your Git central repo and start using it.

I recommend you to give it a try, it will save you a lot of work - I know it, I put that work into the code wink

This widget could not be displayed.

You cannot put hooks inside the .git folder in such a way that they will apply to everybody who clones the repo, since the .git folder is not under source control. You can create a folder in your repo where you store your hooks and ask everybody to copy the contents inside the .git folder locally.

(Or install the hooks on the server only, so non-conforming pushes are rejected.)

This widget could not be displayed.

hi ,

but i want to apply that hooks to all users, i have build some script for commit message , so i need everyone to use it. pl tell me from where that .git file comes, means in server where shall i change the .git folder so that it will be permanent in the every users .git folder.

This should have been written as a comment under the answer you are replying to, not as an answer itself.

You could create a .sh file ( and tell new collaborators to run this script after they cloned the repo. Take a look at this: In the last line: echo "Installing git hooks..." ln -sf ../../validate-commit-msg.js .git/hooks/commit-msg

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,310 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you