fatal: http://myserverip/home/git/example.git/info/refs not found: did you run git update-server-info on the server?

Followed this example to set up a git repository on my server. It worked, and I successfully pushed my code to it.

But now, how do I pull or clone?

Using the docs, I tried

git clone http://REMOTE_SERVER/home/git/example.git

.. But for me, I’m getting:

fatal: http://myserverip/home/git/example.git/info/refs not found: did you run git update-server-info on the server?

I ran git-update-server info, but nothing changed

Edit:

Ah, hold on. I changed it to git clone ssh://REMOTE_SERVER/home/git/example.git and I’m getting something.. it wants my user/pass, but how do I make the server public then not requiring login?

Best Answer

Share over apache http

Preparing the repository

# On the web server we assume var/git as the central repository place and will create a new project-X dir
$ cd /var/git
$ mkdir project-X
$ cd project-X

# now we initialize this directory
# but instead of using git init, we use  git --bare init
# "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory
# , so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need copies of the
 files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself."
$ git --bare init

Now that we created the project directory we need to give apache access to it:

  • Be sure to set the correct permissions on the /var/git directory so that it can be read by the webuser. chown -R apache:apache /var/git/project-X
  • If you have selinux enabled: chcon -R -t httpd_sys_content_t /var/git/project-X
  • Enable the post-update hook: chmod +x /var/git/project-X/hooks/post-update

When you did not set the post commithook:

$ git clone http://git.yourdomain.com/project-X
Initialized empty Git repository in /Users/mydir/project-X/.git/
fatal: http://git.yourdomain.com/project-X.git/info/refs not found: did you run git update-server-info on the server?

Then you can need to run it manually the first time

$ cd /var/git/project-X
$ sudo -u apache git update-server-info

Preparing apache
This document assumes you have a basic apache setup. And you have virtual name server working. Most of it is standard acces to the directory.
To allow write access, we need to have Webdav enabled.
http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt

<VirtualHost some-ip:80>
	Servername git.mydomain.com
	DocumentRoot /var/git
	<Directory "/var/git">
	   DAV On
	   Options +Indexes +FollowSymLinks 
		AllowOverride None
		Allow from all
		Order allow,deny
	</Directory>
</VirtualHost>

This will add a virtual server that has access to the /var/git directory using simple browsing.
In case you are experiencing trouble:

  • Remove the restrictions from welcome.conf: in this default file, it disables the index option. Error: …
  • Note the + before the options, to allow the merge of permissions

Controlling access
We control access to your repository using apache groupfiles and password files

<VirtualHost YOUR-IP:80>
	ServerName git.yourdomain.com
	DocumentRoot /var/git
	<Directory /var/git/>
		DAV On
		Options ExecCGI FollowSymLinks Indexes
		# Deny everyything here
		Deny from all
		AuthType Basic
		AuthName "git repository"
		AuthUserFile /var/git/htpasswd.git
		AuthGroupFile /var/git/htgroup.git
	</Directory>

	<Directory /var/git/project-X>
		Allow from all
		Order allow,deny
		<Limit GET>
			Require group project-X-read
		</Limit>
		<Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
			Require group project-X-write
		</Limit>
		</Directory>
</VirtualHost>

Accessing the repository
Git uses curl to access http repositories. Because our repository is now protected we need to create an entry in our $HOME/.netrc file

$ cat $HOME/.netrc
machine git.yourdomain.com
login reader
password reader

Now you should be able to clone project-X

$ git clone http://git.mydomain.com/project-X

Possible Errors

Trying update
error: Cannot access URL http://git.yourdomain.com/project-X/, return code 22
error: failed to push some refs to 'http://git.yourdomain.com/project-X'

If there’s something wrong with the permissions. Maybe you don’t have webdav enabled, the user is in the wrong group, or filepermissions are not set correctly. Check your apache error_log

$ git clone http://git.yourdomain.com/project-X
$ git push
fatal: git-push is not available for http/https repository when not compiled with USE_CURL_MULTIerror: failed to push some refs to 'http://git.yourdomain.com/project-X'

Either you compile your git client with the correct curl options. Or you can alternatively mount the remote repository as webdav share and access it via file:// references. See http://wiki.dreamhost.com/Talk:Git

The following happens if your curl library  was not compiled with the correct options to post to 
http://kerneltrap.org/mailarchive/git/2008/1/13/564431
After a bit of research it seems that CURL compilation into GIT was not entirely successful for the Git on Mac OS X. As I was already mounting the git repository via WebDAV you an push and pull to your locally mounted repository by replacing the http URL with the path to your mounted WebDAV (/Volumes//). This worked pretty well for me and works well with Dreamhost with very little configuration.

 

$ git push
Fetching remote heads...
   refs/
   refs/tags/
   refs/heads/
   No refs in common and none specified; doing nothing.

This happens when you cloned an empty repository:

Because you cloned an empty repository , you need to specify the origin and master , after this first push, you can use git push as usual

$ git push origin master

Sharing repository using apache and gitweb

By default, the apache does not provide a friendly view of the repository. To allow a better web interface, you can use git-web. This is a python script.
Before you take this option, be sure to setup the simple apache http first. This allows you to better check where the problem lies.

Installing gitweb

# Easy gitweb installation on Centos,Redhat, which installs itself in /var/www/git by default
$ yum install gitweb
# You have to manually create a /etc/gitweb.conf file
   $GIT= "/usr/bin/git";
   $projectroot = "/var/git/";

Gitweb provides a nice interface but if you would have it take control of your web rendering, git would be confused.
To solve this we allow different ways to access the same repository:

  • Using http://git.yourdomain.com/project-X.git : using AliasMatch we can map this to the traditional index rendering
  • With http://git.yourdomain.com/project-X : this will show the gitweb interface
<VirtualHost YOUR-IP:80>
	SetEnv GITWEB_CONFIG /etc/gitweb.conf
	ServerName git.yourdomain.com
	DocumentRoot /var/www/git
	AliasMatch ^(/.*?)(\.git)(/.*)? /var/git$1$3
	<Directory /var/git/>
		DAV On
		Options ExecCGI FollowSymLinks Indexes
		# Deny everyything here
		Deny from all
		AuthType Basic
		AuthName "git repository"
		AuthUserFile /var/git/htpasswd.git
		AuthGroupFile /var/git/htgroup.git
	</Directory>

	<Directory /var/git/project-X>
		Allow from all
		Order allow,deny
		<Limit GET>
			Require group project-X-read
		</Limit>
		<Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
			Require group project-X-write
		</Limit>
		</Directory>

	
	<Directory /var/www/git>
		Options ExecCGI FollowSymLinks Indexes
		Allow from all
		Order allow,deny
		AddHandler cgi-script cgi
		DirectoryIndex gitweb.cgi
		RewriteEngine on
		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
	</Directory>
	
</VirtualHost>

Controlling Access
Similar to the Apache http Repository
Publish your local repository
Similar to the Apache http Repository but now you need to use the .git extension

$ git clone http://git.yourdomain.com/project-X.git

A very common error

$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'file:///share/projects/project-X'

If you have gone through the steps of git remote add origin …., you might think that git would be smart enough to now that a git push needs to go to your origin.
The first time after adding this, you can’t use the default git push, but you have to specify the full path

	$ git push origin master

Another way to solve this is to add the following lines to your .git/config file

$ vi .git/config
        [branch "master"]
        remote = origin
        merge = refs/heads/master

Or stil another way is to specify the option while you add the remote http://swedishcampground.com/adding-a-remote-to-existing-git-repo

        
$ git remote add --track master origin file:///share/projects/project-X

You may Also Like:

Leave a Comment