Reputation: 9402
I set up git as per the instructions here. However, after creating a test file, committing it, and pushing it to the server, I do not see the file anywhere under the git directory. I was hoping that it would show up somewhere that the web server on the machine could see it, so that pushes would immediately show up for http requests to the server.
I know that git is supposed to be a bit more self-contained and on the client side the files form a nice package that could be used in this way. Does the server not do the same thing?
Update: I initially didn't use the "bare" option. But when I did this, and I tried to do the initial commit from the remote, I got a big error message I don't really understand.
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 to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
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 some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
Since I never checked anything out, I don't know what it means by this or what I am supposed to really do.
Upvotes: 4
Views: 5377
Reputation: 26515
What seems to be one repository at your client side is actually two things. The actual repository located in .git
and your working tree which usually contains the files corresponding to the currently checked out commit.
Both are quite independent. The working tree is only used to make your changes and update the repository afterwards.
Even though it first seems like you are inside your "repository", you are actually in your working tree. From there you can ask the repository in order to update your files or add your files to new commits inside the repository. - But your repository will never by itself change your working tree.
Your remote repository is a bare repository, i.e. it is only the repository without a working tree. This is needed in order to be able to push arbitrary branches.
Because it is missing a working tree you cannot see the files anywhere. (And even if there would be some working tree, it would not be clear what files to show. After all your repository contains many commits, all with different content.)
To actually "see" those files the easiest way is cloning your repository into the directory of your web server and check out the correct branch. - Of course you need to update this repository, whenever the main repository changes. This can be achieved by using a hook inside the main repository. A post-receive-hook would be fine in this case.
Upvotes: 8
Reputation: 8446
It is good practice to make 'upstream' repositories bare. That way you won't be tempted to edit files on the server without accountability (server repos are typically owned by non-personal accounts).
To facilitate what you need, you can clone the repository on the server and export that through a web server (read-only).
Upvotes: 0