I don't really know where to go with this one and have tried everything I can think of.
I have a GitLab server running on Ubuntu 14.04. I've creating a post-receive hook script (bash) that clones the repo to a new folder in the /tmp directory and then copies the files out to a mounted remote directory. If I run the script while logged into the git user the script runs fine, but when it runs as the hook-script it does not. The script starts running fine but the result of the git clone command is a totally empty folder. Not even any repo files. Also, I don't get any error from the clone command. The clone command only returns a single line:
(my command) git clone file:///var/opt/gitlab/git-data/..../999.git 999
(return) Cloning into '999'
Again, if I run the same clone command from the command line from the same user I don't have this issue, so I don't think it's a permission thing.
Any pointers on where I can go from here?
Thanks!
I cannot reproduce this problem, but that may be because your Git version is older than mine (mine is 2.8.1 and 2.6 added new options for separate work directories that changed a lot of the code in question; I don't know what version you have, but I am betting it predates 2.6). So this may not be the correct solution, but then again, it might. :-)
When hook scripts run, they have an environment variable, GIT_DIR
, set to the path containing the repository. For post-receive
s this is always just .
(the post-receive hook runs in the repository directory). It seems likely that this is causing your clone to fail.
If so, simply unset GIT_DIR
in your script before doing the git clone
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.