Note that there are some explanatory texts on larger screens.

plurals
  1. POGit push from post-update hook fails - X is not a repository
    primarykey
    data
    text
    <p>I am trying to setup a central repository that will automatically push to another repository when it is pushed to from my local machine. I have been Googling for several days now and I have tried every command combination I could find with no luck.</p> <p>The setup: I first created the central repository as a bare and then cloned it to the second machine as a non-bare. I added the second machine as a remote, called "www", to the first machine. I confirmed that I could execute "git push www master" manually from the first machine and it will update the second via SSH. I then cloned the repository to my local development machine via HTTP. I can push from local to central just fine.</p> <p>My post-update hook in its current form:</p> <pre><code>#!/bin/bash cd /var/git_repos/site.git unset $(git rev-parse --local-env-vars) branch=$(git rev-parse --abbrev-ref HEAD) if [ "$branch" == "master" ]; then echo "Pushing $branch to www..." env -i git push www master fi exec git update-server-info </code></pre> <p>I have cobbled this together from various SO and blog posts. It works fine when executed manually from the CLI of the first machine ("cd /var/git_repos/site.git/hooks; ./post-update") but I get the error message "www is not a Git repository" when executed as a hook.</p> <p>The output:</p> <pre><code>$ git push Password: Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 264 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: Pushing master to www... remote: fatal: 'www' does not appear to be a git repository remote: fatal: The remote end hung up unexpectedly To https://xxx@git.xxx.xxx/site.git e3d3a1d..103c819 master -&gt; master </code></pre> <p>Can anyone tell me what I am doing wrong?</p> <p><strong>Edit:</strong> I have figured out that my initial issue was that the permissions on site.git were not entirely set correctly. Having fixed that problem, I have a new problem.</p> <p>New output:</p> <pre><code>$ git push Password: Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 332 bytes, done. Total 3 (delta 1), reused 0 (delta 0) remote: I am apache &lt;---- Output of "whoami" for debugging remote: Pushing master to www... remote: ssh: connect to host 192.168.1.79 port 22: Permission denied remote: fatal: The remote end hung up unexpectedly To https://nnn@git.nnn.nnn/site.git 29d504c..f14f201 master -&gt; master </code></pre> <p>I have tried adding the following to my /etc/sudoers file with no luck:</p> <pre><code>apache ALL=NOPASSWD: /usr/bin/ssh </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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