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 [email protected]: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?
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)
Make a new post-update hook in the bare repository containing the following lines:
Make sure it's executable
Push a commit to the bare repository and note the lines starting with
remote:
to see if any errors occurred.