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
0
votes
2 answers

pre-commit hook to read commit message

How to read commit message from git commit -m "message" using pre-commit hook. Or Is there any hook that reads commit message. commit-msg hook can read the message but we need to provide a text file as input which I don't want.
0
votes
2 answers

Unable to get input from user in shell script which is called by git hook pre-push script

I am running a shell script from another shell script which is a git-hook pre-push. This is the content of .git/hooks/pre-push: #!/usr/bin/env bash protected_branch='master' current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') if […
npatel
  • 1,081
  • 2
  • 13
  • 21
0
votes
1 answer

Git pre-push hook doesn't seem to be working with git push

I am on my testbranch: $git branch master * testbranch Here is my code in .git/hooks/pre-push file: #!/bin/bash protected_branch='testbranch' current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') if [ $protected_branch =…
npatel
  • 1,081
  • 2
  • 13
  • 21
0
votes
1 answer

How to get the msbuild path returned from "nuget.exe restore"

I'm new to using git hooks and now I'm trying to restore nuget packages for the projects in my solution and after that build the solution. What I did is create a git hook 'post-merge' and added the following…
Koen van Ras
  • 15
  • 10
0
votes
1 answer

How to test validity of es6 imports before commit

I have a react/redux based large codebase comprising of the following hierarchy: Routes >> Container >> Components which means that Routes contain Containers and Containers contain Components. I'm using a lot of es6 import across my code - to import…
Probosckie
  • 1,585
  • 4
  • 25
  • 40
0
votes
1 answer

Docker-compose services build & deployment workflow

Recently I started making a REST API. My plan was to use React.js, Flask and Postgres all being created with docker-compose during development and then in production use React and Flask services with docker-compose but make the database run on VPS…
Davkk
  • 23
  • 1
  • 5
0
votes
1 answer

Git extra hook, pre-upload

I'm a university student. Currently, I’m doing my Final Year Project that requires a hook that executes automatically on the server side of the repository, before the objects been pulled to the client side, and after the objects have been pushed to…
Kenneth128
  • 11
  • 1
  • 3
0
votes
1 answer

odd hook script execution on git

This is a little weird so I have this line in my remote git repo hook script post-receive: cd /path/to/my/deployed/app git reset --hard rm files/.development And from my local machine i push to my git repo - here's what's weird. Those lines that is…
David
  • 4,235
  • 12
  • 44
  • 52
0
votes
1 answer

How to call script maintained in repo during pre-receive

Suppose I have a unit-test script maintained under my git. I would like to create a pre-receive hook to call this unit-test. However pre-receive should be installed at server side. In my repository, the directory structure looks completely different…
Yan Zhu
  • 4,036
  • 3
  • 21
  • 37
0
votes
1 answer

Nothing happens on git pull hook (post-update)

when I do a git pull on live server I'm logged in as root and so all modified or new files user and group are set to root:root. I've tried this set up in my post-update hook file: OWNER="example:example" REPO_PATH="/home/example/public_html" cd…
MikeeeG
  • 331
  • 1
  • 5
  • 21
0
votes
2 answers

Hook Type to Exclude File Types from Git Repository

I am trying to write a git hook that will prevent files such as .exe files from being pushed to repositories. We use Gitlab for our source control and this hook will function in place of the Gitlab 'Prohibited file names' push rule. My question is:…
Seán
  • 523
  • 2
  • 10
  • 17
0
votes
1 answer

Local `commit-msg` doesn't work in conjunction with global `prepare-commit-msg`

When I have my global git hooks directory (which contains just a prepare-commit-msg hook) set up in config, my local commit-msg doesn't run (although the global hook does). However, when I disable the global prepare-commit-msg hook (by commenting…
shreyasminocha
  • 550
  • 3
  • 14
0
votes
0 answers

Auto setting custom hooks while cloning git repository?

Once I cloned the Bitbucket repository, under .git/hooks I'm able to see the pre-commit hook, and I have tested the execution with my own conditions to execute before commit. Now I want the same pre-commit hook script to be shared within the team,…
N Surya
  • 1
  • 1
0
votes
0 answers

Git server-side pre-receive hook

I am working on enforcing git pre-commit hook as a server-side pre-receive or an update hook and unable to find proper examples on achieving it. I was able to successfully implement/test the pre-commit hook #!/bin/bash echo "Running pre-commit…
Opps
  • 59
  • 1
  • 8
0
votes
1 answer

Setup automatice database migration on Heroku after push

I've managed to setup my Heroku app to deploy automatically on a git push to Github. I see that Heroku itself offers Deploy Hooks, but those seem meant for integration with other services. What I'd like to do is see if any changed files containing…
kontur
  • 4,934
  • 2
  • 36
  • 62