0

First of all thank you for this wonderful website (yes I'm new, at least as a writer :p).

Since I didn't found here an answer for my problem I will try to ask help directly :) I saw here that maybe it will be HTTP related but I don't know this post is quite old now ...

The main problem:

I want to make some hook to run on the remote server (on a Linux system).

When I try to act like a Client doing with TortoiseGit a clone then trying to commit and push some modifications, all is completed without launching any remote script present in the .git/hooks folder on the remote server repository. I tried with a script named update, and with pre-receive. Those script have a echo "hello" and it doesn't print anywhere when launching.

What I've already checked:

The extension ".sample" is gone, the scripts can be executed, they are own by the good user account, I did manage to make hooks work on the client side (like prepare-commit-msg).

A more detailed example:

In order to go further I did try to commit and push not through TortoiseGit on Windows (like the client) but directly a sort of local testing on the Linux server (to investigate closer to the problem before trying again with TortoiseGit...).

git clone http://{ID}@{serv}.corp/git/{FOLDER}/{REPO}.git .
Cloning into '.'... 

(the clone is okay), then switch to a test branch

git checkout test_hook
Branch test_hook set up to track remote branch test_hook from origin.
Switched to a new branch 'test_hook'

(the branch I've created to test hooks)

Commit some random modifications

git commit -a -m "test command line"

[test_hook a464a3e] test command line
 1 file changed, 1 insertion(+), 1 deletion(-)
 mode change 100644 => 100755 Makefile

And finally pushing

git push --progress "origin" test_hook:test_hook
Fetching remote heads...
  refs/
  refs/tags/
  refs/heads/
updating 'refs/heads/test_hook'
  from 6d65df53f962a12e8445a137de173f50eeade819
  to   a464a3ef2cfca3648a4b7b4e94f377f13b82f852
    sending 3 objects
    done
Updating remote server info
To http://{ID}@{serv}.corp/git/{FOLDER}/{REPO}.git
   6d65df5..a464a3e  test_hook -> test_hook

I tried to place the script both in the {FOLDER}/{REPO}.git/hooks/ folder and the main {FOLDER}/hooks

Even with the hooks script like :

#!/bin/sh
# Testing Server-sided hooks
echo "Hello"
echo "Cancelling push."
exit 1

The push finished ok and doesn't print anything ...

If you have ideas to help me that will be welcome thanks you :)

PS : Bonus question :

I did try to simply add the script that I did manage to launch prepare-commit-msg to the folder of my repository in {FOLDER}/{REPO}.git/hooks. But why when I clone this repo the local .git/hooks doesn't contain my script but only the samples, why? (that would have been an easy solution to make a script that will be cloned each time locally while cloning the repo.

EDIT : formatting

Yue Lin Ho
  • 2,945
  • 26
  • 36
  • Hooks are not copied from server to local when cloning. A server would generally be a bare git repository (no seperate .git folder) and the folder name should be `hooks` not `hook`. See [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) – crashmstr Mar 28 '17 at 14:02
  • Sorry i was indeed talking about /hooks :) missed an "s"... That's sad if hooks were copied when cloned that would solve my problem ... – StellarNear Mar 28 '17 at 14:20

0 Answers0