The Android source is managed by repo. When syncing using repo, a directory called .repo/projects/ is created, which contains all the git repositories also checked out directly in the current working directory, just in bare git format.
For what purpose does repo maintain the bare git repositories? And how are these bare repositories used by repo?
(NB: Clarification: I am not talking about a git repository when I write “repo”, I am talking specifically about the script called repo created by/for Android for maintaining all the git repositories comprising the Android source.)
After working with the Android repo manifest system for a while, I think I now understand the purpose of the bare repositories in the
.repo/projects/directory.As already answered by @Fredrik the projects there are not another copy of the repositories represented directly in the “clone” created by
repo. In fact the content of all the.gitdirectories in the clone are just symlinks, like this:Thus the actual git repositories are only represented once in a clone.
The reason for keeping a bare and a normal git are then because of the way the manifest system works. The manifest system is a way of specifying a collection of gits that will be checked out, and in which version they will be checked out. The manifest file is itself maintained in a git, and the repo command allows changing the branch of that manifest git as you please.
Thus to allow a (fast) way of removing and adding gits depending on what is currently picked in the manifest file, repo can just keep all the gits you have ever cloned in the
.repo/projectsfolder, and then only copy them to the “normal” clone area if they are chosen in the current branch of the manifest file.