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
1 answer

How to recieve return value from python script to pre-commit hook

As apart of pre-commit hook i want to run a python script that returns a success value to a hook some thing like that: pre-commit hook result=python test.py if result exit 0 test.py ..running some tests... return 1 is there any way to do that…
aGuy
  • 83
  • 5
0
votes
2 answers

git add hook / getting git to ignore file modes of new files

I'm working with a git repository on both windows and linux/mac. When I create new files on windows, or edit them in some text editors, the file mode is changed to 775. I can get git to ignore file mode changes with git config core.filemode…
Jason Gross
  • 5,928
  • 1
  • 26
  • 53
0
votes
2 answers

Retain committed files through failed pre-commit hook

I have a pre-commit hook that runs some linting like so: ./gradlew app:ktlint --daemon status=$? if [ "$status" = 0 ] then echo "${green}Linting found no problems.${reset}" exit 0 else echo 1>&2 "${red}Linting found issues.${reset}" …
davy307
  • 309
  • 3
  • 16
0
votes
1 answer

Git Hook - core.hookspath not picking up local hooks

I am trying to point my repositories gitconfig to my local git hooks directory so that every developer on my team can download this directory and not have to worry about updating the default hooks everytime they clone a repo. I've created a local…
Peter
  • 11
  • 4
0
votes
1 answer

Is it possible to configure default or global git hooks?

Using Git for a long time now, I'm used to having my config variable specific for each project and some global under ~/.gitconfig. Or same for ~/.gitignore for global exclusion rules depending on my OS. I'm wondering if something like this is…
Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
0
votes
1 answer

How I can prompt git users to login everytime they push?

we are hosting gitlab on our server with only https authentication. Users can login either through webui or shell. With a web UI everything is working as desired. The use case is when user is getting authenticated over shell, we trigger our custom…
0
votes
1 answer

Auto pull from GitHub repository on remote DigitalOcean server after push from local machine?

I have a project that I push to a GitHub repository from my local machine. I deploy this project on a DigitalOcean droplet that I currently have to ssh into and do a git pull, then redeploy manually. Is there an easy way to have it auto pull, and…
0
votes
2 answers

No such file or directory error on commit hook

This is my pre-commit hook #!/bin/sh echo "pre-commit started" filename="$1" lineno=0 error() { echo "$1" exit 1 } while read -r line do [[ "$line" =~ ^#.* ]] && continue let lineno+=1 length=${#line} if [[ $lineno -eq…
niksmac
  • 2,667
  • 3
  • 34
  • 50
0
votes
1 answer

Git hook for branch name

Is it possible to create a Git hook that would prevent creating a brach name not meeting some specific requirements? Say I want to allow only branch names composed with [-a-z/] (small letters, / and -, i.e. disallow capital letters). Commit or post…
Greg
  • 8,230
  • 5
  • 38
  • 53
0
votes
1 answer

Git pre-commit hook that prevents a commit if there are upstream changes

Say I am working on feature/foo...isn't there a way to prevent a git commit if there are changes to remotes/origin/feature/foo? Is there any advantage in incorporating the changes before making a new commit? The only thing I can think of is to force…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Bitbucket custom pre-receive hook for preventing unknown users to commit

Currently due to collaboration across different vendors and contractors sometimes they use a malformed git config at the client side when checking in code Once the code is checked in, bitbucket does not reconcile the correct username against the…
sudhakar
  • 33
  • 1
  • 6
0
votes
0 answers

Git post-update hook doesn't get executed

Good afternoon, I'm trying to setup my VPS so it automatically pulls changes I've pushed to my BitBucket repo. I've created a post-update script, given it executable flags, executed it manually to see if it does what I want (yes, it does, without an…
JTinkers
  • 1,631
  • 9
  • 18
0
votes
0 answers

Script stops, although "set -e" was set afterward read

I have a script for a git post-receive hook read oldrev newrev refname set -e echo DELETE rm -rf * echo DELETED ... When I run the script, the ouput looks like this remote: DELETE But then the script stops. But when I remove the "set -e" or…
William M.
  • 369
  • 1
  • 5
  • 10
0
votes
1 answer

VSTS Continuous Integration - Change SDK path

I'm looking for a solution for a problem. That is arise during Continuous Integration. To run the build command on my agent I have to give the path of the sdk of my server where build is going to be run. Normally the local.properties files are not…
eC Droid
  • 651
  • 2
  • 9
  • 26
0
votes
1 answer

How can I configure a user's git hook folder to match the project's

Our project is on a server which is running as a git server. We are running on Windows machines to interact with that server. I am in the process of developing a pre-commit git hook. The first question is whether git will look for that hook in the…
DaveS
  • 101
  • 3