2025-11-10:

git vs git --bare

Your git repository could exist in two instances: normal and --bare. Normal is a ~git-client, not normal is a ~git-server. Not exactly, but --bare exists to be a remote in normal repositories. And it also doesn't have files inside.

You can create on your VPS a --bare repository and via ssh synchronize it, avoiding any services like github. And everyone with ssh access can use it as a remote.

Astoundingly, when you create normal it creates a directory for itself <repo>/.git</repo>, but when --bare it uses the given path as .git.

$ git init ./git-normal/
Initialized empty Git repository in /tmp/.dotfiles/git-normal/.git/
$ git init --bare ./git-bare/
Initialized empty Git repository in /tmp/.dotfiles/git-bare/

$ ls -lah git-normal/ .git/ $ ls -lah git-bare/ hooks/ info/ objects/ refs/ HEAD config description

Funny joke: if you put --bare in ./.git/, it will look like ./ has a git repository, and it is there, but it is not!

fatal: this operation must be run in a work tree

#linux #howto #man #git