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

  • Git hooks are prohibited on most commercial Git services like GitHub, Bitbucket or GitLab, for security reason. Those propose which are only able to send a JSON payload to a 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 an alternative to Git hooks.

Useful Links

1768 questions
1009
votes
7 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
  • 15,010
  • 11
  • 58
  • 90
499
votes
15 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
  • 208,672
  • 30
  • 90
  • 92
418
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
  • 77,653
  • 43
  • 148
  • 164
322
votes
28 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
  • 3,887
  • 4
  • 19
  • 24
319
votes
4 answers

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

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/ directory instead of in the hooks…
swanson
  • 7,377
  • 4
  • 32
  • 34
306
votes
10 answers

Putting Git hooks into a 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
  • 23,119
  • 19
  • 77
  • 102
284
votes
17 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
  • 4,178
  • 3
  • 20
  • 26
241
votes
17 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
  • 11,415
  • 7
  • 28
  • 22
181
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
  • 23,618
  • 9
  • 46
  • 48
158
votes
4 answers

How can I manually run a Git pre-commit hook, without attempting a commit?

I just want to be able to run it to see if the code in my working tree passes it, without actually attempting a commit.
callum
  • 34,206
  • 35
  • 106
  • 163
141
votes
4 answers

How to remove git hooks

I had set up a git hook in pre-commit file to run git pull before any commit. Now I have deleted that file and restarted my computer multiple times, but that hook is still running before my commits. How can I remove or disable that completely?
Ali Farhoudi
  • 5,350
  • 7
  • 26
  • 44
118
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
  • 11,397
  • 8
  • 56
  • 61
106
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,691
  • 3
  • 30
  • 18
102
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,969
  • 10
  • 59
  • 94
101
votes
8 answers

How can I automatically push after committing in Git?

How do I set Git to automatically push to a remote repository (including automatically providing my passphrase) after each commit to the local repository?
ulu
  • 5,872
  • 4
  • 42
  • 51
1
2 3
99 100