5

1. I followed the following tutorial to setup git for web development on my private server.

Using git for Deployment

Im getting the following error while using

git push origin master

fatal: http://mysite.com/.git/info/refs?service=git-receive-pack not found: did you run git update-server-info on the server?

I followed through various questions on stackoverflow which all points to creating a repository before using git push but i already have a git repository.

2 . When i visit mysite.com/.git , the complete .git repository is displayed. How do i disable this and just enable git push to the same.

wdphd
  • 905
  • 6
  • 15
  • 25

1 Answers1

3

A remote url like http://mysite/.git is certainly not a valid one.

It should refer to a bare repo name like, from the tutorial you reference, 'myproject/.git':

git remote set-url origin dan@server:/var/git/myproject.git

(Replace dan by the user account you used to setup a git repo in /var/www/myproject).


The OP wdphd confirms it works, but the non-bare repo isn't updated.

That is because the hook is pushing to "hub", and that remote need to be declared:

cd /var/www/myproject/.git
git remote add hub /var/git/myproject.git

(easier than editing /var/www/myproject/.git/config directly)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks this worked! I made some changes to my local server and pushed it to my private server. But the changes are still not reflected. – wdphd Oct 13 '13 at 18:23
  • @wdphd probably because you are pushing to a non-bare repo, which is,'t recommended. You need to `git checkout master` in your server destination repo for its working tree to update itself. – VonC Oct 13 '13 at 18:32
  • @wdphd see for why a non-bare repo is not updated by a push: http://stackoverflow.com/a/3761891/6309. And regarding bare repos: http://gitolite.com/concepts/bare.html – VonC Oct 13 '13 at 18:41
  • No, im not pushing into non bare repo. From the tut: $ cd /var/git/myproject.git $ git init --bare $ cd /var/www/myproject $ git push /var/git/myproject.git master – wdphd Oct 13 '13 at 18:42
  • @wdphd then it seems normal to not see any file in a bare repo. The `post-update` hook should update the non-bare repo though. Make sure it is executable (`chmod 755`). – VonC Oct 13 '13 at 18:45
  • Rechecked the whole code again. It still says everything upto date – wdphd Oct 13 '13 at 19:08
  • @wdphd and you do have a `/var/git/myproject.git/hooks/post-update` file, executable? And you have a remote named "`hub`" correctly declared? What `git remove -v` returns when executed in `/var/git/myproject.git`? – VonC Oct 13 '13 at 19:29
  • Yes, the post-update hook is executable. git remote -v in /var/git/myproject.git doesn't return anything. But i have added [remote "hub"] url = /var/git/myproject.git fetch = +refs/heads/*:refs/remotes/hub/* into `/var/www/html/.git/config` – wdphd Oct 13 '13 at 19:40
  • @wdphd I have edited the answer to make the necessary steps (regarding the hook) clearer. – VonC Oct 13 '13 at 19:46
  • Thanks for the update man. When i try to add the remote hub, it already exists. I'm a beginner in git so please excuse me for this extended discussion – wdphd Oct 13 '13 at 20:02
  • @wdphd sure, if you already edited the config file manually, you don't have to do a `git remote add`: it would indeed already exist. I was just pointing out the 'git' way to add a remote. – VonC Oct 13 '13 at 20:10
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/39151/discussion-between-wdphd-and-vonc) – wdphd Oct 13 '13 at 20:11