What are the purpose of the bare git repositories in .repo/projects/ created by the Android repo script?

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?

  • How to add an already existing branch in an already existing Android Repository on Eclipse
  • Git commit to a sub-directory inside a repository by Android Studio
  • How do I get my current build commit's sha1 in Android Studio?
  • How do I merge between branches when the package name is different?
  • “Add to VCS” disabled in Android Studio
  • Project from https://android.googlesource.com
  • (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.)

  • How can I pull in changes to a file from a subdirectory in another git repository
  • Remove 'credential-osxkeychain'
  • Split a Subversion Repository Project to Two Git Repositories
  • Find Git commit given just a version of file
  • Where is git repository of Xcode stored? And Why different repository is created when I copy project directory?
  • Git - Remove commit from history
  • 3 Solutions collect form web for “What are the purpose of the bare git repositories in .repo/projects/ created by the Android repo script?”

    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 .git directories in the clone are just symlinks, like this:

    $ ll development/.git/
    total 452
    drwxr-xr-x  2 bfh bfh   4096 2011-08-15 13:55 ./
    drwxr-xr-x 20 bfh bfh   4096 2011-08-15 13:55 ../
    lrwxrwxrwx  1 bfh bfh     43 2011-08-15 13:55 config -> ../../.repo/projects/development.git/config
    lrwxrwxrwx  1 bfh bfh     48 2011-08-15 13:55 description -> ../../.repo/projects/development.git/description
    -rw-r--r--  1 bfh bfh     41 2011-08-15 13:55 HEAD
    lrwxrwxrwx  1 bfh bfh     42 2011-08-15 13:55 hooks -> ../../.repo/projects/development.git/hooks/
    -rw-r--r--  1 bfh bfh 449008 2011-08-15 13:55 index
    lrwxrwxrwx  1 bfh bfh     41 2011-08-15 13:55 info -> ../../.repo/projects/development.git/info/
    lrwxrwxrwx  1 bfh bfh     41 2011-08-15 13:55 logs -> ../../.repo/projects/development.git/logs/
    lrwxrwxrwx  1 bfh bfh     44 2011-08-15 13:55 objects -> ../../.repo/projects/development.git/objects/
    lrwxrwxrwx  1 bfh bfh     48 2011-08-15 13:55 packed-refs -> ../../.repo/projects/development.git/packed-refs
    lrwxrwxrwx  1 bfh bfh     41 2011-08-15 13:55 refs -> ../../.repo/projects/development.git/refs/
    lrwxrwxrwx  1 bfh bfh     45 2011-08-15 13:55 rr-cache -> ../../.repo/projects/development.git/rr-cache/
    lrwxrwxrwx  1 bfh bfh     40 2011-08-15 13:55 svn -> ../../.repo/projects/development.git/svn

    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/projects folder, and then only copy them to the “normal” clone area if they are chosen in the current branch of the manifest file.

    It’s not two copies, .git folder in a component contains symlinks towards the corresponding component in ./repo/projects

    Disclaimer: I’m far from an expert with Git.

    I think you’re saying that when you checkout code you get two copies. One is the working copy (where you specified it should be copied to) and another is kept in .repo/projects. Assuming I have interpreted the question correctly, my best guess would be that the copy in .repo/projects is kept so that you can quickly do comparisons with and revert to the base revision that you checked out without having to go back to the server. I think it is quite common for VCSs to do that. SVN does it by putting a .svn folder in all of the folders of your working copy and putting the base revision files in them.

    Git Baby is a git and github fan, let's start git clone.