从命令行确定但钩(git) [英] from command line ok but the hook (git)
问题描述
我想在任何人推入远程回购后自动更新我的redmine项目资源库。目前红酒中的杜松子酒已经起作用。但在使用钩子自动更新之后,我得到在存储库中找不到条目或修订。
in redmine。
要在redime中设置git,我遵循 redmine wiki ,以便通过裸创建回购 git clone --bare
更新redmine的git存储库我使用 cd /srv/www/redmine.domain.com/git_repositories/linode.git&& git fetch&& git reset --soft refs / remotes / origin / master
- 手动更新命令行下的
git
用户可以正常工作
/ p>
remote:计数对象:5,完成。
remote:压缩对象:100%(3/3),完成。
remote:合计3(增量2),重用0(增量0)
解包对象:100%(3/3),完成。
从domain.com:linode
* [new branch] master - >起源/主
- 运行form
post-receive
钩子(请参阅上面的错误)。在同一个用户(git)下运行。钩子的第一行是#!/ bin / sh
< 配置: git(1.7.0.4)+ ubuntu上的gitolite(1.5.7)
我检查了GIT_DIR系统变量byt命令SET
remote:/srv/www/redmine.domain.com/git_repositories/linode.git[K
remote:GIT_DIR ='。'[K
I甚至试图通过
export 来设置 git path
export GIT_DIR = / srv / www / redmine.domain.com / git_repositories / linode.git
或取消设置GIT_DIR
钩子的结果
echoPost receive-hook =>更新Redmine存储库
#env -i git reset --hard
#unset $(git rev-parse --local-env-vars)
#unset GIT_DIR
cd /srv/www/redmine.domain.com/git_repositories/linode.git
pwd
git fetch
git reset --soft refs / remotes / origin / master
我s
推送到git@domain.com:linode
remote:Post receive-hook =>更新Redmine存储库[K
remote:from domain.com:linode[K
remote:/srv/www/redmine.domain.com/git_repositories/linode.git[K
remote:4755447 .13b8e3d master - >原产地/主人[K
至git@domain.com:linode
4755447..13b8e3d master - > master
我尝试了调用-git-pull-from-a-git-post-update-hook 和git-post-receive-hook-with-git -pull-failed-to-find-a-valid-git-directory 但没有任何帮助
更新
$ p
$ b
echoPost receive-hook =>更新Redmine存储库
export GIT_DIR =
cd /srv/www/domain.com/git_repositories/linode.git
echo重置工作树...
git reset --hard
回显完成重置工作树。
git fetch
git reset --soft refs / remotes / origin / master
我得到这个+ redmine存储库是不变的,可以从redmine访问
推送到git@domain.com:linode
remote:Post receive-hook =>更新Redmine存储库[K
remote:重置工作树... [K
remote:致命:不是git存储库:''[K
remote:完成重置工作树[K
remote:fatal:不是git存储库:''[K
remote:fatal:不是git存储库:''[K
到git@domain.com:linode
c553a15 .854d159 master - > master
Update2
我发现如果我从钩子执行 git fetch
,然后从命令执行 git reset --soft refs / remotes / origin / master
行它不工作。我在redmine中遇到上述错误。我从命令行执行 git fetch
,然后一切正常。来自hook和commnand的'git fetch'命令的控制台消息看起来与我一样。
我确切地知道什么和为什么在通过钩子(我使用gitolite)执行 git fetch
之后,一些文件(也许是新的)有权限redmine`不喜欢。
chmod -R 770 redmine_repo.git
做了这个把戏
I want to automatically update my redmine project repository after anybody pushes into remote repo. Currently gin in redmine is up and works fine. But after automatic update using a hook I get The entry or revision was not found in the repository.
in redmine.
To set up git in redime I followed redmine wiki so the repo is bare created via git clone --bare
To update redmine's git repository I use this cd /srv/www/redmine.domain.com/git_repositories/linode.git && git fetch && git reset --soft refs/remotes/origin/master
- manual update if running from command line under
git
user works ok
the screenshot when executed manually is
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From domain.com:linode
* [new branch] master -> origin/master
- the same doesn't work correctly when running form
post-receive
hook (see the error above). Runs under the same user (git). The first line of the hook is#!/bin/sh
configuration: git (1.7.0.4) + gitolite (1.5.7) on ubuntu
I checked the GIT_DIR system variable byt command SET remote: /srv/www/redmine.domain.com/git_repositories/linode.git[K remote: GIT_DIR='.'[K
I even tried to set git path
up in the hook by
export GIT_DIR=/srv/www/redmine.domain.com/git_repositories/linode.git
or unset GIT_DIR
but nothing helped.
The result of the hook
echo "Post receive-hook => updating Redmine repository"
#env -i git reset --hard
#unset $(git rev-parse --local-env-vars)
#unset GIT_DIR
cd /srv/www/redmine.domain.com/git_repositories/linode.git
pwd
git fetch
git reset --soft refs/remotes/origin/master
is
Pushing to git@domain.com:linode
remote: Post receive-hook => updating Redmine repository[K
remote: From domain.com:linode[K
remote: /srv/www/redmine.domain.com/git_repositories/linode.git[K
remote: 4755447..13b8e3d master -> origin/master[K
To git@domain.com:linode
4755447..13b8e3d master -> master
I tried few hints from calling-git-pull-from-a-git-post-update-hook and git-post-receive-hook-with-git-pull-failed-to-find-a-valid-git-directory but nothing helped
Update
if I try
echo "Post receive-hook => updating Redmine repository"
export GIT_DIR=
cd /srv/www/domain.com/git_repositories/linode.git
echo "Resetting working tree..."
git reset --hard
echo "Finished resetting working tree."
git fetch
git reset --soft refs/remotes/origin/master
I get this + redmine repository is untouched and accessible from redmine
Pushing to git@domain.com:linode
remote: Post receive-hook => updating Redmine repository[K
remote: Resetting working tree...[K
remote: fatal: Not a git repository: ''[K
remote: Finished resetting working tree.[K
remote: fatal: Not a git repository: ''[K
remote: fatal: Not a git repository: ''[K
To git@domain.com:linode
c553a15..854d159 master -> master
Update2
I found out that if I do git fetch
from the hook and then git reset --soft refs/remotes/origin/master
from command line it doesn't work. I get the above error in redmine. I do git fetch
from command line then everything works fine. Console messages from both hook and commnand line 'git fetch` commands looks the same to me.
I do know exactly what and why but after git fetch
executed via hook (I use gitolite) some files (maybe new ones) has permissions that redmine `doesn't like.
chmod -R 770 redmine_repo.git
did the trick
这篇关于从命令行确定但钩(git)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!