3

I created a remote repository for a number of my projects, so it is the destination of my push's. Contrary to the ideology of git, but it serves as a central repository.

However when I go to the *.git folders on the server there is a directory structure of the form:

 - /branches
 - /hooks
   - applypatch-msg.sample
   - commit-msg.sample
   - etc
 - /info
   - exlude
 - /objects
   - 06
   - 1c
   - various hex numbers
   - pack
 - /refs
   - /tags
   - /heads
     - master
 - config
 - description
 - HEAD

What is going on here, I'm sure if I studied the inner working of git I would be able to figure it out, but where are the project files?

Update

I created the repo in the following way:

  1. Had an existing local git repository
  2. Added remote to the local git remote add origin git@site.co.za:project_name.git
  3. On the server, created a base repository of the same name 'git init --bare project_name.git`
  4. Pushed from local to remote git push origin master
tread
  • 10,133
  • 17
  • 95
  • 170
  • "Contrary to the ideology of git, but it serves as a central repository." say what? – jthill Jan 05 '14 at 10:45
  • The project files are packed as objects and are in /objects/*. You can look at them, but need to use git commands to do so. What are you trying to achieve? – iveqy Jan 05 '14 at 12:09
  • I was trying to access the project files on the remote repository (server's repository) but could not find them, @VonC answered the question saying there is no working tree which I was looking for – tread Jan 05 '14 at 16:11

2 Answers2

7

When you are pushing to a bare repo (see "all about "bare" repos -- what, why, and how to fix a non-bare push"), you won't see your file in that repo, because by definition it has no working tree.

You can add a post-receive hook (like illustrated in this post-receive hook) in order to checkout (and see) your files:

/path/to/bare/repo.git/hooks/post-receive:

cd /path/to/bare/repo.git
GIT_WORK_TREE=/path/to/live/server git checkout -f

If you just want to see at the list of files (or their content) stored in that bare repo, you can do it without even having to clone said bare repo.
See "Accessing files of a repository from the Git server", provided you have a direct access to the bare repo server.

GIT_DIR=/path/to/bare.git git log --pretty=format: --name-only --diff-filter=A | sort | grep .
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When pushing to a remote (non bare) i get: `remote: error: refusing to update checked out branch: refs/heads/master By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent with what you pushed, and will require 'git reset --hard' to match the work tree to HEAD.` – tread Jan 06 '14 at 10:17
  • @StevieG that seems to be working as designed. Could you push to a bare repo instead? – VonC Jan 06 '14 at 10:18
  • yes, also when pushing to the non-bare remote it would fail but works if it is bare – tread Jan 06 '14 at 10:19
  • @StevieG Exactly. Note: if you just want to look at the list of files in a bare repo, I have edited the answer to point out a way to do just that. – VonC Jan 06 '14 at 10:21
0

Git does not store your files in a way that you can just look at them. I guess you can see that :)

You can only look at the files managed by a git repository in a checkout of that repository. You need to tell us how you crated the remote repository for us to be able to tell you where you can look on that remote server, but it may be "nowhere" if that remote repository is "headless" (IE doesn't have a checkout).

GreenAsJade
  • 14,459
  • 11
  • 63
  • 98
  • updated question with additional required details – tread Jan 05 '14 at 09:52
  • OK - so you created a "bare" repository. This means that there are no files checked out on the remote end (a fairly sensible thing to do). You can't look at the files on the remote side in this case. – GreenAsJade Jan 05 '14 at 09:55