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'