tags:

views:

539

answers:

2

I have a local repository called TestRepo. I clone it with the --bare option, zip this clone up, and throw it on my server. Unzip it, and it's still bare.

I then clone the bare remote repository locally over ssh with something like

git clone ssh://[email protected]/~/TestRepo.git TestRepoCloned

The local TestRepoCloned is not bare and has a remote called "origin." It appears to be tracking correctly from the looks of its config file

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://[email protected]/~/TestRepo.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

I edit an existing file. I commit the change to the current branch (master) via

git commit -a -m "Edited a file."

The commit succeeds and all is well.

I decide to push this change to the remote repository via SSH with a

git push

The remote repository is now no longer bare, but has a complete working directory, and I get continuous error messages on all further attempts to push to it.

Everything I've read seems to suggest that what I'm doing is correct, but it simply is not working. How am I supposed to push changes to a bare remote repo and actually keep it bare?

+3  A: 

This shouldn't happen. My guess is that there is either some sort of hook script (probably post-receive), which causes a checkout or that there's a bug in Git. Both of these aren't very likely, but that's the only thing I can imagine.

Jörg W Mittag
+1  A: 

It might be possible that zip/unzip does not preserve file permission (e.g. executable bit) and thus activates some previously deactivated hooks. You might want to check hook permissions on server or skip the whole zip part and just create bare repository directly on the server and upload our data using regular git push.

che
You're close. It seems to preserve the executable bits just fine, but the hooks directories I've unzipped only contain .sample files. Everything in all of these files is commented out, so I have no idea what could possibly be running, but I don't see the problem if I do the init --bare on the server and then "remote add origin" locally. In that case I have many more files in the hooks directory, though I have no idea why. Both local machine and server are running the same Git version, but local is OS X and remote is RedHat something or other.
Azeem.Butt
The hooks are private to the machine, they are never cloned, pushed or pulled. The sample hooks are created locally by whatever version of Git you are using. If your client and server have different versions of Git, they will create different sample hooks.
Jörg W Mittag
Well I've never touched any hooks directories anywhere, so if Git is creating something that cannot be moved to another machine when I make a bare clone of an existing repository then that sure smells like a bug to me.
Azeem.Butt