Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've made a remote git repository with

mkdir /var/www/html/myproject.git
chmod 0770 /var/www/html/myproject.git
ln -s /var/www/html/myproject.git myproject.git
cd myproject.git
git --bare init

and successfully connected to it and cloned it on my own machine with

git clone git@myserver.co.uk:myproject.git

then uploaded some files to it

git push

which when tried again shows that the repository is already up to date.

However, I'm looking around on the remote server, and can't actually find where git has stored those files! It's not in /var/www/html/ nor /home/git and the only thing I've managed to find is the HEAD file which contains the id of the initial commit I made in /var/www/html/myproject.git/refs/heads/master. (So I know the push worked)

Where could the files possibly be?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The answer is actually all of the files are stored in the objects/pack directory as hashed files when in the bare repository. You cannot directly obtain the files from there.

If anyone by chance was trying to do what I did and have a set of files on the server that are manageable by git (for example, a web server), then you need to do this instead:

Make a clone of the repository where you want the files to be accessible (make sure git can write to it, especially the .git directory inside)

mkdir /path/to/clone/repo
chmod -R 0775 /path/to/clone/repo
cd /path/to/clone/repo
git clone /path/to/bare/repo.git

Make a new post-update hook in the bare repository containing the following lines:

vi /path/to/bare/repo.git/hooks/post-update
#!/bin/sh
# Update the real-file cloned repository
unset GIT_DIR
cd /path/to/cloned/repo
git fetch
git reset --hard

Make sure it's executable

chmod a+x /path/to/bare/repo.git/hooks/post-update

Push a commit to the bare repository and note the lines starting with remote: to see if any errors occurred.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.