从命令行可以,但是钩子(git)
我想在有人推送到远程存储库后自动更新我的 redmine 项目存储库。目前redmine中的杜松子酒已经启动并且工作正常。但是在使用挂钩自动更新后,我在 redmine 中得到 The entry or revision was not found in the repository.
。
为了在 redime 中设置 git,我遵循了 redmine wiki,因此存储库是通过 < code>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
用户下从命令行运行可以正常,
但手动执行时的屏幕截图是
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
- 相同的运行表单
post-receive
挂钩时可以正常工作(请参阅上面的错误)。在同一用户(git)下运行。钩子的第一行是#!/bin/sh
configuration: ubuntu 上的 git (1.7.0.4) + gitolite (1.5.7)
我检查了 GIT_DIR 系统变量通过命令SET 远程:/srv/www/redmine.domain.com/git_repositories/linode.git[K Remote: GIT_DIR='.'[K
我什至尝试在钩子中设置 git path ,
export GIT_DIR=/srv/www/redmine.domain.com/git_repositories/linode.git
or unset GIT_DIR
但没有任何帮助。
挂钩的结果
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
是
Pushing to [email protected]: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 [email protected]:linode
4755447..13b8e3d master -> master
我尝试了 calling-git 的一些提示-pull-from-a-git-post-update-hook 和 git-post-receive-hook-with-git-pull-failed-to-find-a-valid-git-directory 但没有任何帮助
更新
如果我尝试,
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
我得到这个 + redmine 存储库未受影响,可以从 redmine
Pushing to [email protected]: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 [email protected]:linode
c553a15..854d159 master -> master
Update2
访问,我发现如果我从钩子中执行 git fetch ,然后 git reset --soft refs/remotes/origin /master 从命令行它不起作用。我在redmine中遇到上述错误。我从命令行执行 git fetch ,然后一切正常。来自钩子和命令行“git fetch”命令的控制台消息对我来说看起来是一样的。
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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我确实知道具体是什么以及为什么,但是在通过钩子(我使用 gitolite)执行 git fetch 后,某些文件(可能是新文件)具有 redmine 不喜欢的权限。
成功了
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.did the trick