Questions tagged [githooks]

Git hooks are scripts that are executed upon certain git events. Events include, but are not limited to, pre- and post-commit and pre- and post-rebase on the client-side, and post-receive-commit on the server-side. No need to use the tag Hooks when using the tag Githooks. Maybe used in combination with tag Webhooks

What is it ?

Git hooks are scripts that are executed upon certain git events. Events include, but are not limited to, pre- and post-commit and pre- and post-rebase on the client-side, and post-receive-commit on the server-side.Hooks can be written in most any scriptable language, including ruby, perl, bash, and shell.

Related tags

  • Githooks are prohibited on most commercial Git services like GitHub, BitBucket or GitLab, for security reason. These propose which are only able to send a JSON payload to an url (like a push).
  • Use for other hooking mechanisms in the source management or build process that do not rely on git hooks.
  • Use for webhooks used on Github as alternative to githooks.

Useful Links

1583 questions
648
votes
4 answers

Skip Git commit hooks

I'm looking at a git hook which looks for print statements in Python code. If a print statement is found, it prevents the git commit. I want to override this hook and I was told that there is a command to do so. I haven't been able to find it. …
Ben
  • 10,944
  • 9
  • 52
  • 88
416
votes
19 answers

Deploy a project using Git push

Is it possible to deploy a website using git push? I have a hunch it has something to do with using git hooks to perform a git reset --hard on the server side, but how would I go about accomplishing this?
Kyle Cronin
  • 72,761
  • 40
  • 144
  • 160
387
votes
13 answers

Can Git hook scripts be managed along with the repository?

We'd like to make a few basic hook scripts that we can all share -- for things like pre-formatting commit messages. Git has hook scripts for that that are normally stored under /.git/hooks/. However, those scripts are not propagated when…
Pat Notz
  • 186,044
  • 29
  • 86
  • 92
289
votes
4 answers

Applying a git post-commit hook to all current and future repos

I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) git repositories I am working on. I tried adding the hook to my ~/.git/hooks/ instead of in the hooks directory in…
swanson
  • 6,952
  • 4
  • 30
  • 33
226
votes
16 answers

Make Git automatically remove trailing white space before committing

I'm using Git with my team and would like to remove white space changes from my diffs, logs, merges, etc. I'm assuming that the easiest way to do this would be for Git to automatically remove trailing white space (and other white space errors) from…
mloughran
  • 10,067
  • 7
  • 26
  • 21
225
votes
9 answers

Putting git hooks into repository

Is it considered to be a bad practice - to put .git/hooks into the projects repository (using symlinks, for example). If yes, what is the best way to deliver same hooks to different git users?
shabunc
  • 17,863
  • 15
  • 68
  • 96
223
votes
16 answers

Git push error pre-receive hook declined

I have run gitlabhq rails server on virtual machine, following 1-6 steps from this tutorial https://github.com/gitlabhq/gitlab-recipes/blob/master/install/centos/README.md and starts rails server executing command sudo -u git -H bundle exec rails s…
Hroft
  • 2,827
  • 2
  • 16
  • 24
211
votes
13 answers

update package.json version automatically

Before I do a small release and tag it, I'd like to update the package.json to reflect the new version of the program. Is there a way to edit the file package.json automatically? Would using a git pre-release hook help?
tUrG0n
  • 3,408
  • 3
  • 16
  • 26
157
votes
1 answer

How can I have linked dependencies in a git repo?

In my scripts, I often use libraries (mine or others') that have their own repos. I don't want to duplicate those in my repo and get stuck with updating them every time a new version comes out. However, when somebody clones the repo, it should…
Lea Verou
  • 22,372
  • 9
  • 43
  • 47
102
votes
11 answers

Git hook to send email notification on repo changes

How do I configure the appropriate Git hook to send a summary email whenever a set of changes is pushed to the upstream repository?
Head
  • 4,391
  • 3
  • 28
  • 18
100
votes
3 answers

Are git hooks pushed to the remote when I 'git push'?

If I create a new hook script in my local repository in repo/.git/hooks/post-commit and then I run "git push" are the hooks pushed to the remote? Then, when the other developers run "git pull" from the same origin will they get my new hooks?
slacy
  • 10,495
  • 7
  • 51
  • 60
93
votes
5 answers

getting "fatal: not a git repository: '.'" when using post-update hook to execute 'git pull' on another repo

I'm new to git so I apologize (and please correct me) if I misuse terminology here, but I'll do my best. I'm trying to set up a bare git repo (hub) and a development site working copy (prime) on a web server. I've tried to pattern it after this…
Ty W
  • 6,406
  • 4
  • 26
  • 34
92
votes
13 answers

How can I automatically deploy my app after a git push ( GitHub and node.js)?

I have my application (node.js) deployed on a VPS (linux). I'm using git hub as a repository. How can I deploy the application automatically, on git push ?
Advanced
  • 1,437
  • 2
  • 13
  • 12
88
votes
8 answers

How to automatically push after committing in git?

How do I set git to automatically push to a remote repo (including automatically providing my passphrase) after each commit to the local repo?
ulu
  • 5,182
  • 3
  • 37
  • 48
88
votes
6 answers

Symbolic link to a hook in git

I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the…
Mateusz Dymczyk
  • 14,171
  • 8
  • 55
  • 90
1
2 3
99 100