# Pre commit/push hooks

**URL:** <https://discuss.dgraph.io/t/pre-commit-push-hooks/125>\
**Category:** Users\
**Created:** [April 27, 2016, 5:53am UTC](https://discuss.dgraph.io/t/pre-commit-push-hooks/125 "2016-04-27T05:53:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [April 27, 2016, 5:53am UTC](https://discuss.dgraph.io/t/pre-commit-push-hooks/125/1 "2016-04-27T05:53:05Z")

</div>

I did my research on this and would like to share it with you guys and get your advice on it.

As I had suspected, there is no direct way to have repository wide hooks. Git hooks are installed in `.git/hooks` directory. Even if we decide to centralize the code for hooks, we would have to make a `hooks` directory in the DGraph repository. Then each developer would have to symlink this directory with the `.git/hooks` directory on his machine.

I suggest we don’t need this for now. We could set up a pre-push hook on our individual machines. Pre-commit is also fine, but if you commit often and have small changes, you might not want to run the tests on every commit.

Setting up these hooks is a very easy.

You just have to make a file called `pre-push` inside your `.git/hooks` directory in your DGraph repo. Note the file is without any extension. Add the line

`go test github.com/dgraph-io/dgraph/...` to it.  
Make the file executable. And Tada you have the hook setup. Now every time you try to push tests will be automatically run.

Let me know what your thoughts @mrjn and @ashwin95r are.

References - 1. [http://stackoverflow.com/questions/427207/can-git-hook-scripts-be-managed-along-with-the-repository](http://stackoverflow.com/questions/427207/can-git-hook-scripts-be-managed-along-with-the-repository)  
2. [Using Git Hooks to improve your workflow | by Pawan Rawal | Medium](https://medium.com/@pawan_rawal/using-git-hooks-to-improve-your-workflow-61c3829f5397#.8i4ev5930)

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [April 27, 2016, 6:23am UTC](https://discuss.dgraph.io/t/pre-commit-push-hooks/125/2 "2016-04-27T06:23:33Z")

</div>

Sounds great! Simple and effective.

At some point, we’ll still need the Travis CI integration – but we can wait until v0.3 release. Think we already have a Trello card to track that task.

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [April 27, 2016, 6:25am UTC](https://discuss.dgraph.io/t/pre-commit-push-hooks/125/3 "2016-04-27T06:25:30Z")

</div>

> [@mrjn](#):
>
> At some point, we’ll still need the Travis CI integration – but we can wait until v0.3 release. Think we already have a Trello card to track that task.

Yes, we do have a card.

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [November 28, 2017, 1:00am UTC](https://discuss.dgraph.io/t/pre-commit-push-hooks/125/4 "2017-11-28T01:00:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
