Note that there are some explanatory texts on larger screens.

plurals
  1. POfrom command line ok but the hook (git)
    primarykey
    data
    text
    <p>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 <code>The entry or revision was not found in the repository.</code> in redmine.</p> <p>To set up git in redime I followed <a href="http://www.redmine.org/wiki/1/RedmineRepositories" rel="nofollow noreferrer">redmine wiki</a> so the repo is bare created via <code>git clone --bare</code></p> <p>To update redmine's git repository I use this <strong><code>cd /srv/www/redmine.domain.com/git_repositories/linode.git &amp;&amp; git fetch &amp;&amp; git reset --soft refs/remotes/origin/master</code></strong> </p> <ul> <li>manual update if running from command line under <code>git</code> user works ok</li> </ul> <p>the screenshot when executed manually is</p> <pre><code>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 -&gt; origin/master </code></pre> <ul> <li>the same doesn't work correctly when running form <code>post-receive</code> hook (see the error above). Runs under the same user (git). The first line of the hook is <code>#!/bin/sh</code></li> </ul> <p><strong>configuration:</strong> git (1.7.0.4) + gitolite (1.5.7) on ubuntu</p> <p>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</p> <p>I even tried to set <code>git path</code> up in the hook by </p> <pre><code>export GIT_DIR=/srv/www/redmine.domain.com/git_repositories/linode.git or unset GIT_DIR </code></pre> <p>but nothing helped.</p> <p>The result of the hook</p> <pre><code>echo "Post receive-hook =&gt; 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 </code></pre> <p>is </p> <pre><code>Pushing to git@domain.com:linode remote: Post receive-hook =&gt; 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 -&gt; origin/master[K To git@domain.com:linode 4755447..13b8e3d master -&gt; master </code></pre> <p>I tried few hints from <a href="https://stackoverflow.com/questions/3542854/calling-git-pull-from-a-git-post-update-hook">calling-git-pull-from-a-git-post-update-hook</a> and <a href="https://serverfault.com/questions/107608/git-post-receive-hook-with-git-pull-failed-to-find-a-valid-git-directory">git-post-receive-hook-with-git-pull-failed-to-find-a-valid-git-directory</a> but nothing helped</p> <h2>Update</h2> <p>if I try</p> <pre><code>echo "Post receive-hook =&gt; 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 </code></pre> <p>I get this + redmine repository is untouched and accessible from redmine</p> <pre><code>Pushing to git@domain.com:linode remote: Post receive-hook =&gt; 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 -&gt; master </code></pre> <h2>Update2</h2> <p>I found out that if I do <code>git fetch</code> from the hook and then <code>git reset --soft refs/remotes/origin/master</code> from command line it doesn't work. I get the above error in redmine. I do <code>git fetch</code> from command line then everything works fine. Console messages from both hook and commnand line 'git fetch` commands looks the same to me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload