4

I have a Debian running Nginx on git.example.com which I use to store git repositories.

I can pull/push/clone via SSH by running git clone [email protected]/git/my_repo. (git is a symlink in my home directory which points to /mnt/primary_storage/git)

However, when I clone/pull with HTTP(S) I get the following error:

fatal: http://git.example.com/my_repo.git/info/refs not valid: is this a git repository?

I get this error regardless of whether I am cloning a real repository

The relevant part of the Nginx config is:

server {
  listen       80;
  server_name  git.example.com;

  root /mnt/primary_storage/git;


  location ~ (/.*) {
    auth_basic "Login";
    auth_basic_user_file /mnt/primary_storage/.htpasswd;
    include       fastcgi_params;
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param GIT_PROJECT_ROOT    /mnt/primary_storage/git;
    fastcgi_param PATH_INFO           $1;
    fastcgi_pass localhost:9000;
  }   
}

The annoying thing is that I had the exact same setup running on another server which had Ubuntu and it worked fine. So I don’t know what is causing this. Apart from this one problem everything on the server is running fine.

Yes there are a few similar questions like this on StackExchange sites but none are helping me. For example some of them are dealing with Github and they hadn’t set up the repository first. Others had the Git address wrong. And Others said I should run git config --global http.proxy which didn't help.

Also I have triple checked all of the folder/file permissions and they are all readable and writable from the Nginx user.

0

3 Answers 3

2

In order to properly pull over HTTP (or any other protocol that supports packing), you need to do the packing manually.

You can do this by running git update-server-info while in the repository directory.

It might be handy to put this in the post-update Git hook in the repo, so it is done automatically when you push.

mtak@gen1:/srv/git/puppet.git/hooks$ cat post-update 
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".

exec git update-server-info
1
  • Hi @mtak. Thanks for your reply. I have tried this and it doesn't seem to do anything. I don't know what kind of debug info to give you since there is no output.
    – KNejad
    Oct 26, 2017 at 10:45
1

This error message is the same as saying "The repository doesn't exist".

Check if the URL you are using is shown under Fetch and Push for the command:

git remote show origin

This should give a result like [email protected]:[REPO-NAME].git.

If the URL is wrong, you may fix it by the command :

git remote set-url origin [REPO-URL]
1
  • What is the difference between "info/refs not valid" and "info/refs not found" then? Since I have gotten that in the past and seen it online. I assumed that error meant no repo exists and "not valid" meant it found the repo but something was wrong. I can't run git remote show origin since I don't actually have a cloned repo. My problem is with HTTP. SSH works fine.
    – KNejad
    Nov 17, 2017 at 20:46
0

Make sure the git repo you're trying to access supports the HTTPS protocol?

Also note that the repository name is case sensitive.

Also, make sure the repository URL is reachable from your network. Maybe there is port 443 problem (https).

Make sure the proxy is set correctly for git if you're behind a proxy!

git config --global http.proxy

See also info here: https://confluence.atlassian.com/bbkb/info-refs-not-valid-is-this-a-git-repository-313467635.html

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .