Cannot pull from Git repository over HTTP/HTTPS but can with SSH
Solution 1
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
Solution 2
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]
Related videos on Youtube
KNejad
Updated on September 18, 2022Comments
-
KNejad over 1 year
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.
-
KNejad over 6 yearsHi @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 over 6 yearsWhat 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.