It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

2 votes
Answer accepted

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: http://git-scm.com/book/es/v2/Customizing-Git-Git-Hooks 

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

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.)

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 (init-repo.sh) and tell new collaborators to run this script after they cloned the repo. Take a look at this: https://github.com/angular/angular.js/blob/master/init-repo.sh 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 in Bitbucket

Atlassian supported Jenkins integration for Bitbucket Server

We’ve been building a plugin to integrate Bitbucket Server and Jenkins CI, and I’m excited to announce that our alpha is ready to download and install. It lets you seamlessly configure a Jenkins job ...

1,035 views 3 17
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you