how to make `git --bare` with all files within `.git/`

57 Views Asked by At

I am using bare repositories in addition to git worktree add to manage to handle multiple branches at the same time.

It turns out git clone --bare moves all files from .git/ to ./, and it is very hard to look for the added branches among all the files of .git/ in ./.

My goal is to have the following tree structure:

./
├── .git/
├── branch1/
├── branch2/
└── branch3/
.
.
.

How can I do that?

1

There are 1 best solutions below

3
mkrieger1 On

Directories containing bare repositories are by convention named <project name>.git.

You can just rename and move the directories containing the bare repository, and the different worktrees, to a common parent directory.

parent/
├── project.git/
├── branch1/
├── branch2/
└── branch3/

Naming the bare repository .git would make the parent directory into a Git repository, which you explicitly don't want.