3

I've used SVN for years, but I want to test Git for the first time.

I tried to use HTTP protocol in order to keep my previous credentials (made with htpasswd).

I followed this procedure on my server:

$ aptitude install git-core apache2
$ mkdir -p /var/git/repositories
$ htpasswd -c /var/git/passwd my_account
$ cat > /etc/apache2/sites-available/git << EOF
<VirtualHost *:80>
    ServerName git.mydomain.com

    SetEnv GIT_PROJECT_ROOT /var/git/repositories
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

    ScriptAlias / /usr/lib/git-core/git-http-backend/

    DocumentRoot /var/git/repositories

    <Directory /var/git/repositories>
        Options +ExecCGI +SymLinksIfOwnerMatch -MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    <Location />
        AuthType Basic
        AuthName "Git Access"
        AuthUserFile /var/git/passwd
        Require valid-user
    </Location>
</VirtualHost>
EOF

$ a2ensite git
$ service apache2 reload

$ cd /var/git/repositories
$ git init --bare my_project.git
$ git update-server-info

On my client, I do this:

$ git clone http://git.mydomain.com/my_project.git
$ cd my_project
$ cat > test-file.txt << EOF
This is a test
EOF
$ git add test-file.txt
$ git commit -m "My first commit"

Everything seems to be okay for now.

As I want my content to be updated by my remote repository, I do git pull, but this doesn't work. Git returns the following message :

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

Anyway, I'm alone on my code. I'll try to fix it later. Let's try to push to the server.

So I do git push.

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date

Okay... "doing nothing" but "Everything is up-to-date"?

After a little check, I find and execute, the following command : git push origin master This time I have the following message :

error: unpack failed: unpack-objects abnormal exit
To http://git.mydomain.com/my_project.git
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'http://git.mydomain.com/my_project.git'

I tried to follow many tutorials on the web.

I think my configuration is simple, so I can't understand why it doesn't work.

Thanks for anyone who can help me.

EDIT :

I restarted from scratch, following http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html

I don't need gitweb. I just want to use HTTP protocol with Git client.

So my virtualhost is :

<VirtualHost *:80>
    ServerName git.mydomain.com

    SetEnv GIT_PROJECT_ROOT /var/git/repositories
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

    ScriptAlias / /usr/lib/git-core/git-http-backend/

    DocumentRoot /var/git/repositories

    <Location />
        AuthType Basic
        AuthName "Git Access"
        AuthUserFile /var/git/passwd
        Require valid-user
    </Location>

</VirtualHost>

I have exactly the same errors.

git pull returns :

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

and git push origin master returns :

error: unpack failed: unpack-objects abnormal exit To http://git.mydomain.com/my_project.git ! [remote rejected] master -> master (n/a (unpacker error)) error: failed to push some refs to 'http://git.mydomain.com/my_project.git'

David Cain
  • 16,484
  • 14
  • 65
  • 75
antoine
  • 31
  • 3
  • 2
    What happens if you don't use your password/encryption stuff? As a side note, wouldn't ssh be enough? – Shahbaz Jun 25 '12 at 16:43
  • 1
    SSH could be enough, but with SSH, I am supposed to use "system" accounts rather than accounts in a simple list or a database, right ? And if I simply use SSH, this protocol will make the users able to connect and execute commands. – antoine Jun 26 '12 at 06:28
  • I updated the thread with a simpler way to install GIT server. But it doesn't work yet. – antoine Jun 27 '12 at 09:39

1 Answers1

0

I don't know if this is the answer but I remember I had similar problems because I did not install cgi. So I would install dependencies as root or sudo. (I know I am beating a dead horse with this suggestion. ) Ex on debian stack:

#!/bin/sh

apt-get install git-core
apt-get install curl-ssl
a2enmod cgi
a2enmod alias
a2enmod env

You may be missing the apache cgi module. In theory your apache cfg file looks good, but I would also try to changed those script aliases to an actual name instead of using the root just to make sure that the server isn't doing anything crazy. But I'm with you. I am trying to get Smart GIT HTTP to work on a ubuntu server. I got it going on a Debian, but previous Apache Rewrite Rules were redirecting urls.

I would also not use git init --bare. I would at least create a README File so git can create and a HEAD. Then use git init because GIT has standardized putting a .git/ folder to hold information. git init --bare does not do this. Use git log to view changes. For example do this:

#!/bin/sh

echo >> '' README
git init
git add .
git commit
git log --oneline --decorate --graph
Danuel O'Neal
  • 304
  • 3
  • 4