Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the project files stored in a git repository `.git` folder? [duplicate]

Tags:

git

github

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 [email protected]: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
like image 331
tread Avatar asked Dec 03 '25 22:12

tread


1 Answers

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 .
like image 113
VonC Avatar answered Dec 06 '25 17:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!