Android repo 脚本创建的 .repo/projects/ 中的裸 git 存储库的用途是什么?

发布于 2024-11-09 18:54:56 字数 543 浏览 0 评论 0原文

Android 源存储库。使用 repo 同步时,会创建一个名为 .repo/projects/ 的目录,其中包含所有也直接在当前工作目录中签出的 git 存储库,只是采用裸 git 格式。

repo 维护裸 git 存储库的目的是什么? repo 如何使用这些裸存储库?

(注意:澄清:当我写“repo”时,我不是在谈论 git 存储库,我正在具体谈论名为 repo 由/为 Android 创建,用于维护构成 Android 的所有 git 存储库来源。)

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.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叹倦 2024-11-16 18:54:56

使用 Android 存储库清单系统一段时间后,我想我现在了解 .repo/projects/ 目录中裸存储库的用途。

正如 @Fredrik 已经回答的那样,项目中没有直接在 repo 创建的“克隆”中表示的存储库的另一个副本。事实上,克隆中所有 .git 目录的内容都只是符号链接,如下所示:

$ 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

因此,实际的 git 存储库仅在克隆中表示一次。

保留裸露和普通 git 的原因是清单系统的工作方式。清单系统是一种指定将检出的 git 集合以及将在哪个版本中检出它们的方法。清单文件本身在 git 中维护,并且 repo 命令允许根据需要更改该清单 git 的分支。

因此,为了允许根据清单文件中当前选择的内容(快速)删除和添加 git,repo 可以将您曾经克隆的所有 git 保留在 .repo/projects 文件夹中,然后,如果在清单文件的当前分支中选择了它们,则仅将它们复制到“正常”克隆区域。

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.

×眷恋的温暖 2024-11-16 18:54:56

它不是两个副本,组件中的 .git 文件夹包含指向 ./repo/projects 中相应组件的符号链接

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

最初的梦 2024-11-16 18:54:56

免责声明:我远非 Git 专家。

我想你是说当你结帐代码时你会得到两份副本。一个是工作副本(您指定应将其复制到的位置),另一个保存在 .repo/projects 中。假设我正确地解释了这个问题,我最好的猜测是保留 .repo/projects 中的副本,以便您可以快速进行比较并恢复到您签出的基本修订版,而无需返回服务器。我认为 VCS 这样做很常见。 SVN 通过将 .svn 文件夹放入工作副本的所有文件夹中并将基本修订文件放入其中来实现此目的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文