Recently, I discovered that git could be initialized with a --bare
flag (e.g.
CodePudding user response:
Answering my own question
Do GitHub and similar services use "bare repositories" under the hood?
Yes
It looks like bare git repositories were designed to be used as remote instances and GitHub has to use them to get it to work.
P.S.
It seems that GitHub repository can work as working repository and bare repository at the same time, does that mean GitHub repository is developed from git bare repository
No, Git repos on GitHub are bare, like any remote repo to which you want to push.
Short answer
A bare repository is a git repository without a working copy, therefore the content of .git is top-level for that directory.
Use a non-bare repository to work locally and a bare repository as a central server/hub to share your changes with other people. For example, when you create a repository on github.com, it is created as a bare repository.
So, in your computer:
git init
touch README
git add README
git commit -m "initial commit"
on the server:
cd /srv/git/project
git init --bare
Then on the client, you push:
git push username@server:/srv/git/project master
...