ganjim
ganjim

Reputation: 1416

How to set git hook over HTTP protocol to Automate development on a remote server

I am using git for version control and I want to Automate git to pull everything any of the collaborators push on release branch to a remote server automatically and if I want to do this over ssh, I have to add all of collaborators ssh-keys in my server, but I don't want to give them access to server, so I want to set this git hook over HTTP so that everyone can push to remote server via HTTP protocol

What I have done so far is set a git hook, and I use Nginx as web service and I have put the bare git repository in

/var/www/html/test_repo

and I set my git remote in local computer like this:

git remote add test http://ServerIp/test_repo

but it gives me this error:

fatal: repository 'http://ServerIp/test_repo/' not found

Upvotes: 3

Views: 305

Answers (1)

VonC
VonC

Reputation: 1327784

You need for your NGiNX to call /usr/lib/git-core/git-http-backend in order for git to respond properly to clone/pull commands.

See for instance this answer: it is best if you setup a folder in your URL path to track git repos.

    listen 80;
    server_name myhostname;
    access_log /var/log/nginx/git.access.log;
    error_log /var/log/nginx/git.error.log;
    gzip off;

    location ~ /git(/.*) {
      ...
    }

So the URL for your git repos would be http://ServerIp/git/test_repo, even though the fastcgi_param GIT_PROJECT_ROOT parameter would be /var/www/html

Upvotes: 2

Related Questions