views:

45

answers:

1

Hi,

I have a remote web server that I have full access to (ssh, git, etc.). I want to be able to edit files on my computer and push them to the remote server. When I use a bare repository it doesn't change the file, but when I use a non-bare repository it complains with the following message:

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

Is there any way to get working copies on both my laptop and the remote server?

Thanks

+1  A: 

You can either set that option (on the server):

git config receive.denyCurrentBranch ignore

Or use two repositories on the server side. One is the bare repository that you push to. The other one is a non-bare repository which is a "working copy" clone of the bare repo. You give the bare repo a post-commit hook that cds into your working copy and executes a git pull.

igorw
I wish I could up-vote twice! I didn't know about the post-commit hooks and that sounds perfect for what I need (I didn't want to have to roll my own solution to do exactly what the hook feature does).
Wayne Werner