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

Filter by
Sorted by
Tagged with
1 vote
1 answer
25 views

how to use git hook to validate commit message according to its template

I am trying to use git hook to validate the commit messages of my team. I've configrued the global template: git.exe config --global commit.template .git/.gitmessage Now I would like to create the pre-...
user19370621's user avatar
0 votes
0 answers
21 views

Which Git Hooks are supported by the VS Code built-in Git extension?

It would seem to me that only a few of the Git hooks are supported by the built-in Git extension for VS Code, for example, pre-commit and pre-base hook seem to be, yet others like post-checkout, post-...
B Richardson's user avatar
0 votes
0 answers
11 views

Husky precommit does not run in Windows when using NVM

Followed all the Husky instructions, installed Husky, checked the husky directory was there, but when using nvm in windows, the pre-commit hook does not run. Also used the .huskyrc script suggested in ...
Mickey Puri's user avatar
-1 votes
1 answer
27 views

Git hooks: How to force a file change to be included?

I want to force a *.md change if anything is committed to a specific branch. A CHANGELOG.md where a commit must be translated to non-tech support staff. Pseudo code if branch == master && ...
Jonas Borggren's user avatar
1 vote
1 answer
35 views

Google Cloud Build Doesn't Work Properly on Git Hooks

Im using gcloud and I have a git server on a vm, where in a repository through a git hook (post-receive), Im calling cloud build to triggers the construction of a docker image and the deployment of ...
YosefMac's user avatar
  • 150
-2 votes
0 answers
45 views

why is this git bash not running in a loop?

i have very few experience with macOS and the same is true for bin bash. So I copied some stuff from internet: I'm trying to build a pre checkout skript to rollback migrations which are not present in ...
Charliexyx's user avatar
1 vote
0 answers
18 views

GIT: dealing with pre-receive hook during merge

I have problem with pre-receive hook. My hook checks if commits pushed to the branch contain jira ticket or specific tag. And it works fine. Unfortunately, when I create Pull Request (I'm working with ...
Frendom's user avatar
  • 528
0 votes
1 answer
21 views

Git Pre-Receive Hook Handle Git Rebase

I have a git pre-receive hiook and I was it to be able to determine if a push contains a rebase. I can't seem to find a definitive way to handle this online and wondering if anyone would have any ...
Darragh MacKenna's user avatar
0 votes
1 answer
37 views

Git hooks do not run

I want to run post-receive hook to notify Jenkins to start a new build, but I cannot make Git hooks to run automatically. I tried example hooks in .git/hooks repository, by removing .sample but none ...
Karolis's user avatar
  • 264
0 votes
1 answer
361 views

How to disable ktlint max-line-length standard rule

I'm using ktlint 0.50.0, with Spotless 6.20.0, on AGP 8.1.0. Running spotless as a PreCommit Git hook. Due to the existence of too many old code, I'm trying to disable some rules. The one that gives ...
ivtoto's user avatar
  • 241
0 votes
1 answer
29 views

Source control and terminal conflict (version.json typechange)

I encountered an error when attempting to commit via the VSCode source control. The OUTPUT tab revealed that Git was searching for version.json (which is a symlink) with the incorrect path. After some ...
Bernardo Marques's user avatar
0 votes
0 answers
31 views

Modify File/Git index in pre-merge-commit

I want to change a respository file in a pre-merge commit before it is commied. This should not necessarily have been changed by the merge. The git hook will be more complex later, but the simplest ...
tomko's user avatar
  • 54
0 votes
0 answers
30 views

Husky git hook deletes changes in unstaged files when lint staged fails

I have installed husky to use it as a pre commit git hook. I am also using lint-staged. My package.json has following scripts: "lint-staged": { "src/**/*.{ts,tsx,css,md,json}"...
Leff's user avatar
  • 2,058
0 votes
1 answer
34 views

Fetch refs not associated with a branch

I have a program that runs some scientific tests. I have written a git post-receive hook for the server that runs these tests: When it receives a commit, e.g. deadbeef..., run the program Commit the ...
Zaz's user avatar
  • 46.6k
0 votes
0 answers
42 views

Why command 'git log -g' not run correctly in git server side?

Localy the command git log -g --pretty=%H $refname return the hash commits of the new branch is ok but the same commmand return null when run inside the post-receive hook in server-side. If I remove '-...
João Carlos Sousa's user avatar
0 votes
1 answer
33 views

git init doesn't execute hooks

I am following the steps outlined in the below link to ensure that my hooks are rerun every time upon git init: Getting started with Ctags with Vim and Git. Since I don't have fish installed, I ...
Vinod's user avatar
  • 1,041
1 vote
1 answer
92 views

GIT - invalid revision range in local repositories

I'm trying to force commits to include Jira ticket ID with pre-receive hook. To test it locally I'm using repository as server-side, so I ran: git init --bare server - in hooks/pre-receive I added ...
Frendom's user avatar
  • 528
0 votes
0 answers
26 views

Does the git clean command run any hooks?

I have run git clean -dfix in the working copy of an untrusted codebase, and I am wondering if any git hooks might have been invoked. The git clean docs don't mention hooks at all and the hooks docs ...
P Varga's user avatar
  • 19.2k
0 votes
1 answer
71 views

how to use git diff --name-only with non ascii file names

I have a pre-commit hook that runs files=`git diff --cached --name-only --diff-filter=ACMR | grep -E "$extension_regex"` and performs some formatting on those files before committing. ...
Guiorgy's user avatar
  • 1,425
0 votes
1 answer
58 views

Does pre-receive hook works only on server-side?

I would like to force including jira ticket into commit message. To do it globally I can use pre-receive hook, which is available for GitHub Enterprise, but firstly I would like to test, so in .git/...
Frendom's user avatar
  • 528
4 votes
1 answer
61 views

Inject additional hints into `COMMIT_EDITMSG` during `git-commit`

The problem When I run git commit without -m, git launches a commit message editor with some hints, something like this: # Please enter the commit message for your changes. Lines starting # with '#' ...
cyqsimon's user avatar
  • 2,819
-1 votes
1 answer
61 views

What is `.git`'s search path for binary scripts and how do I configure it?

Git has a unique feature: custom git extensions can be added so long as they are executable scripts on the PATH with the appropriate name scheme: # ~/bin/git-foo #! /bin/bash echo foo $: git foo foo ...
Chris's user avatar
  • 29k
0 votes
0 answers
23 views

How to implement custom checks before starting a git merge?

I would like to implement a custom check which has the option to abort a merge before it's begun, preventing git merge from touching the working tree or repository in any way. The pre-merge-commit ...
Adam Spiers's user avatar
  • 17.4k
0 votes
0 answers
18 views

How can I call .net application/exe in pre-commit hook

I wanted to validate xml file before the file being committed to the repository. For this I have created .net application which accepts the file and validates the xml file and if file is valid it will ...
Debugmode's user avatar
0 votes
0 answers
315 views

what is causing eslint errors in my git pre-commit hook, despite having those folders in .eslintignore?

I'm trying to make a GIt pre-commit Hook so that ESLint rules are kept. when running a git commit I get a list of errors. some of the errors are files that are in the .eslintignore file. the ....
Sara Kay's user avatar
0 votes
1 answer
176 views

Husky: cannot spawn .husky/commit-msg: No such file or directory

I have been working with husky for few years now. We started a new project and was sure to add husky for pre-commit and commit-msg linting. But this time we faced some issue in the windows machine. We ...
AMAL MOHAN N's user avatar
  • 1,456
1 vote
1 answer
38 views

Git BASH - Hook on merge removes line breaks

I am using a git hook in my prepare-commit-msg to automatically prepend branch names to the commit message: #!/bin/sh NAME=$(git branch | grep '*' | sed 's/* //') echo "$NAME"' - '$(cat &...
David's user avatar
  • 5,877
0 votes
0 answers
130 views

Why isn't My Git pre-commit Hook Working with Spring Boot and Gradle?

How to implement Git pre-commit/pre-push hook in Spring boot for gradle project? I have implemented at my project but its not working. Step 1: Created a pre-hook script, let's create pre-commit file ...
Swapnil Thamake's user avatar
-1 votes
1 answer
81 views

Can you develop custom bitbucket remote server hook that can reject pushes?

During my research on how to implement a solution for filtering commits on bitbucket's git repo, i.e. rejecting pushes that introduce invalid changes, I found out about bitbucket's custom plugins and ...
wdc's user avatar
  • 2,638
1 vote
2 answers
94 views

How to push multiple branchs to multiple repository via vscode

I have a repo with 3 branches named 1,2,3, and a public GitHub repository named A, a private GitHub repository named B, a GitLab repository named C. The branch 3 is private. So I want VSCode do this ...
Fengying's user avatar
0 votes
0 answers
45 views

Post Update Git Hook On Local Machine Not Executing

I have an Ubuntu server that runs a production build. Every time I push to the main branch, I want my Ubuntu to pull and run some commands. I created a file called "post-update" in <repo-...
Chaseforyourlife's user avatar
-1 votes
2 answers
244 views

Pre-commit hooks always fails with index.lock already exists

When running the hooks in the pre-commit-config.yaml the hook fix-encoding-pragma e debug-statements fails (remove the # -*- coding: utf-8 -*- for example, but fails) and then i can't proceed to the ...
Fanto's user avatar
  • 367
0 votes
0 answers
75 views

How to call php code sniffer in git hook if some developers work in docker in windows(wsl) and some don't?

I have a git hook that looks something like this: PHPCS_BIN=vendor/bin/phpcs ... OUTPUT=$($PHPCS_BIN $STAGED_FILES) RETVAL=$? exit $RETVAL Before many switched to docker, everything was fine, since ...
Mike's user avatar
  • 51
2 votes
1 answer
110 views

Githooks run inside docker with `git add` leads to `index.lock` troubles

I am running a Git hooks (with Githooks) where I run my pre-commit hook over a docker container: #!/bin/bash docker run -rm -v "$(pwd):/workspace" -w "/workspace" myimage:1.0.0 ...
Gabriel's user avatar
  • 9,022
0 votes
1 answer
32 views

Can I get the string from a git command return?

I'm using git hooks and want to pull before pushing, so, I create the pre-push file. Also, I want to guarantee that my pull return is "Already up to date.". Can I get that string to create ...
nutka's user avatar
  • 1
0 votes
0 answers
77 views

Commit msg hook, how active?

I want use commit msg hook to validate my commit msgs, without node, commitlint and husky. I think that it is possible only with hooks, properly commit-msg hook. I´m using window environment. I'm try ...
Barbosa B's user avatar
1 vote
2 answers
105 views

git hooks: get list of files changed after a pull

I'm trying to create a git hook that checks if there were any updates to a specific folder in the repository. For instance, let's say I am interested in the /public folder. Some colleague makes a ...
raquelhortab's user avatar
-1 votes
1 answer
53 views

When using npm scripts, how can I tell if I am currently running windwos or mac

Since it is a multi-person development, in mac environment, it is required to set chmod + x.usky /pre-commit for projects, but many people may deliberately leave it unset in an attempt to submit the ...
laterday's user avatar
  • 359
0 votes
1 answer
59 views

git | how to sync local repo with remote repo?

I have my local git repo that and I want to attach it to a remote git repo in a way that the remote will be like a read only version of the local git repo and will present everything in the local git ...
user15937765's user avatar
1 vote
0 answers
67 views

git doesn't read environment variables when merging with --no-ff

I have a commit-msg where I use GIT_AUTHOR_NAME for whitelisting specific developers for certain commit message standards. In normal scenarios, GIT_AUTHOR_NAME is always defined and shows the correct ...
Norayr Ghukasyan's user avatar
0 votes
1 answer
38 views

Example of a git hook that prevents old history falsely restored?

In this link Prevent unwanted commit from re-entering git history when doing pulls The accepted answer describes generally the solution of a git pre-push hook that accomplishes the reporter's request. ...
tasosioan7's user avatar
1 vote
1 answer
35 views

Git post-commit hook on Windows results in ".git/index.lock: No such file or directory"

I want to copy my work tree to a different location after each commit on Windows. I added a post-commit hook with following contents: #!/bin/bash # the work tree, where the checkout/deploy should ...
saikon's user avatar
  • 137
0 votes
1 answer
558 views

How to avoid disabling a pre-commit hook?

I am sure it is a repeated question and apologies to bother. I didn't find solution to my usecase yet. I created a pre-commit hook that prevents commit when newly developed code has sonar issues. ...
Manu M's user avatar
  • 57
0 votes
0 answers
48 views

Git before merge hook

I am looking for a hook that triggers before every merge in git. I tried the pre-merge-commit hook with the following code: echo "pre-merge commit hook triggered" But nothing is triggered or ...
Lord Tesla's user avatar
1 vote
1 answer
594 views

IntelliJ pre-commit.com integration

I'm using pre-commit hooks in my project. When I'm doing my commits from the command-line everything is great and the hooks are working but when I try to commit from the IDE it failed with the message:...
lior.i's user avatar
  • 593
0 votes
1 answer
43 views

Is it possible to extract a message from the commit and put it as a topic in the pre-push?

I have almost 3 days thinking about it and I can't find a way to make me add a topic without having to do a git push. Is there any way to modify your push after doing a git push? Let me explain: I'm ...
AntoCode's user avatar
  • 395
0 votes
1 answer
338 views

Pre-commit hook for Java Project

is it possible to set pre-commit hook for java & pom based project? I came across blog https://dwmkerr.com/conventional-commits-and-semantic-versioning-for-java/ and able setup commit-msg and he ...
Sujith's user avatar
  • 173
-1 votes
1 answer
51 views

How do I add symlinks of submodules in project

Hi All is there a way to create symlinks from submodules . Meaning If I have RepoA and RepoB. RepoB is a git submodule of RepoA . with normal git submodule I can achieve this repo structure . RepoA |...
MAR's user avatar
  • 51
-1 votes
1 answer
215 views

Cannot install commit-msg-linter with pnpm: sh: .git/hooks/commit-msg: No such file or directory

Description I can't install commit-msg-linter, all other hooks work fine. Reproduce git init pnpm init pnpm add -D husky pnpm add -D git-commit-msg-linter pnpm exec husky install git add . git ...
ZauJulio's user avatar
-1 votes
1 answer
568 views

Why all the script in my git hooks (pre-commit, post-commit, pre-receive, pre-push etc) do not run?

Why all the script in my git hooks (pre-commit, post-commit, pre-receive, pre-push etc) do not run? Note: this question is not a duplicate; I have try the answer to each of the other questions but ...
kams's user avatar
  • 45

1
2 3 4 5
36