tags:

views:

37

answers:

1

Basically I thought I could use git for deployment as those rails cloud providers as heroku offer. So I created an app on the server, changed to that directory and did a git init in there. Next I created a http server with git-wep pointing that directory. Now I check out, that`s fine too and edit and commit to my repo.

Now, what I want to do next, would be to push to the server and have it update it's working directory as a post commit hook. deployed.

But git won't let me push. Probably I could

You can set 'receive.denyCurrentBranch' configuration variable to 'ignore'

but where would I do that? Where and how could I place the hook?

+2  A: 

It'd be better to have the repository on the server be a bare repository (one that does not actually have a working copy - only the contents of the .git directory), and then use something like git archive | tar -x -C /path/to/htdocs in post-receive-hook to export the files into the served directory.

By using a bare repository as your target, you avoid the issue of pushing to a checked-out branch entirely.

To create a bare repository, pass the --bare flag when you init:

git --bare init
Amber
that git archive | tar -x -C /path/to/htdocs would happen via ssh, or would _that_ be the hook?
Jan Limpens
That would be in the hook script.
Amber
Thanks a lot, I will try that!
Jan Limpens
Do note that I left out a small part - you have to tell git archive which ref to archive. So something like `git archive master` or `git archive HEAD`.
Amber