0

Ok, check this out. I have a mac osx server with git installed. We use it for collaborating on projects. What we want is to be able to push to none-bare repository on the server so that we can view the websites on it. The problem is, a none-bare repository has a user with the master checked out, so were not able to push to the master.

The only way I have found working is to push to another branch and then merge it into the master branch, thats time-consuming and boring.

So, is there a way to push to the master branch on the remote server and be able to view the webpage on the server?

Spoeken
  • 2,291
  • 2
  • 23
  • 36

1 Answers1

1

A common way to deal with this is to have a bare repository with a hook that will checkout HEAD to the correct directory, as described here. Essentially, you would create a post-receive hook that does:

GIT_WORK_TREE=/var/www/whatever git checkout -f

Then you just push to that bare repository in order to deploy. This method the advantage over pushing to a non-bare repository that you won't end up with a .git directory under /var/www/whatever, just the files in your project.

Mark Longair
  • 385,867
  • 66
  • 394
  • 320
  • Thank you, I will check this out. – Spoeken Jun 11 '12 at 14:25
  • ok, say I wan't to have the files in a folder that is in same folder that the git repository is in. in my case the folder where my repository is in is named xsessions, the folder I want the files to be deployed is xsessions/www . how would I write this in the post-receive hook? – Spoeken Jun 11 '12 at 14:47
  • Do you mean you want the files to be deployed to `xsessions/www`? Otherwise I don't understand your first sentence... – Mark Longair Jun 11 '12 at 14:49
  • Sorry, yes I want the files to be deployed to xsessions/www – Spoeken Jun 11 '12 at 14:54
  • Ok, I made it :D all I had forgotten vas to chmod the post-receive file chmod +x hooks/post-receive – Spoeken Jun 11 '12 at 15:15