Creating a bare repository from a repository (let alone from a directory) is not as simple as it should be (but I am used to such problems with git). This Stackoverflow answer was very helpful to me when I tried to figure out how to achieve that.
First, we need to create a repsitory using git init.
We then need to add some content (here: a file and a directory with a file) to the repository, add the content (git add) and commit it:
pushd repo > /dev/null
mkdir dir
cat << EOF > dir/lorem-ibsum.txt
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis
natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.
EOF
cat << EOF > file.txt
It was the best of times, it was the worst of times, it was the age of wisdom,
it was the age of foolishness, it was the epoch of belief, it was the epoch of
incredulity, it was the season of light, it was the season of darkness, it was
the spring of hope, it was the winter of despair
EOF
git add .
git commit -q -m 'init repository'
popd > /dev/null