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-receive hook file displaying unwanted message while executing the hook

GitLab version - 9.3.6 Recently I added the pre-receive hook for blocking the binary file pushing. I can get the expected out in my gitlab testing server machine (below image) Testing Server side displaying message I added the same hook file on the…
Arunkumar
  • 73
  • 1
  • 11
0
votes
1 answer

Ignore multiple directories in git hook

I want to ignore any dist and node_modules directories in my git commit hook. I've tried this: git diff --cached --name-only --diff-filter=ACM | find . -path ./node_modules -prune -o -path './**/dist -prune -o -name '*.js' But it doesn't work. It…
Mike Rifgin
  • 10,409
  • 21
  • 75
  • 111
0
votes
1 answer

Git Hooks to send value to Jira

Im using githooks post commit. Whenever I make a commit I want the post commit to execute in such a way that it sends values or information to the Jira server (URL address) which will receive JSON values through post commit scripts.
adus
  • 79
  • 7
0
votes
1 answer

Zipping files in a post-commit hook not working

I have written script to ZIP last commit on post-commit hook: #!/bin/sh echo "[post-commit] Commit done!" exec < /dev/tty while true; do read -p "[post-commit] Archive this commit? (Y/n) " yn if [ "$yn" = "" ]; then yn='Y' …
Vertisan
  • 720
  • 3
  • 14
  • 34
0
votes
1 answer

Detect merged branches from Git merge commit

I want to know merged branches from merge commit. So, I decide to automatically write a merge message which contains merging branches when the merge happens by using a commit hook. However, this has a problem. I couldn't know which branches are…
Ui-Gyun Jeong
  • 143
  • 1
  • 4
  • 14
0
votes
1 answer

Git Hook - Ruby Code - Interactive Input

I am trying to take input from git hook execution code(commit-msg hook). But the ruby is not able to stop at the input point. And its executing the code as if input is like a puts statement. Here is the code I tried and failed. #!/usr/bin/env…
SV Madhava Reddy
  • 1,858
  • 2
  • 15
  • 33
0
votes
3 answers

Facing Issue while configuring Service-hook for Jenkins build job : Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master

I am working on configuring the Jenkins Build-job from VSTS-Service Hooks. I have completed below for configuring the Build-Job with Service Hooks. The Url which I configure in Jenkin Base URL is…
Eddie
  • 581
  • 3
  • 11
  • 20
0
votes
2 answers

git hooks / pre-receive - how to get all the commit messages on a newly created branch?

i' d like to get all the commit messages (like with git log --format=%s) on a newly created branch. Let' s suppose i' ve 2 commits: abcd - from yesterday bcde - from today . With this code: while read old new ref; do .... done old will be 40…
user2194805
  • 1,201
  • 1
  • 17
  • 35
0
votes
1 answer

Pulling all content on from new Git --Bare

This is what we have Existing website, fully functional and working Added a new --bare repo to a folder outside of public_html (for example deploy.git) We use hooks and can push to the public_html using post-recieve I can't pull all files, only the…
Cookra
  • 78
  • 8
0
votes
1 answer

Need to validate local and remote branch before push

I am trying to create a checkpoint using Pre-push hook in GIT where i am checking if the local branch and the remote branch name is same or not. And allow the push only if local and remote branches are same. I was trying something like this in pre…
Saurabhdv27
  • 39
  • 1
  • 8
0
votes
0 answers

Weird behavior with git post-checkout hook and rebase

About a week ago, for the sake of convenience, I put git rebase into my post-checkout hook. It was working fine until today when whenever I checkout any branch (regardless of whether it is behind or ahead any number of commits from the branch it's…
Emil
  • 2,098
  • 11
  • 25
0
votes
2 answers

GitKraken make message with git hook

Is it possible to make a message in GitKraken so the developer sees if the git hook manipulated his commit ? I write git hooks where some files are not allowed to be send to the server and reset them in the commit. How can I make this visible to the…
Coder949
  • 987
  • 1
  • 8
  • 29
0
votes
1 answer

How can I prevent a file (.json) to be commited with a git hook?

How can I prevent a file (.json) to be commited with a git hook ? I have a .json which is on the server yet. So I can not use an gitignore. But now I do not want to allow anyone to change this file (commit it) because it would break something. I…
Coder949
  • 987
  • 1
  • 8
  • 29
0
votes
1 answer

How to merge git from different repositories into 1 repo

I am working on a project where i am splitting up the entire project into multiple modules which are then being individually developed. I do not want the developers of the individual modules to have access to any other modules or the entire project…
Jude Fernandes
  • 7,437
  • 11
  • 53
  • 90
0
votes
1 answer

fatal: Not a git repository: '.git' error when git pre-commit hook fires but runs fine on commandline

I cloned an existing project on my local. I have a pre-commit bash script that is in the .git/hooks folder. This is what it looks like: #!/bin/bash cd api && php artisan enforcer:check --githook I am changing into the api folder since my git root…
kratos
  • 2,465
  • 2
  • 27
  • 45
1 2 3
99
100