Git 子模块工作流程

发布于 2024-08-08 20:14:22 字数 824 浏览 5 评论 0原文

在我的项目中,我需要使用存储在多个 Git 存储库中的第三方代码。我的项目也存储在(单独的)Git 存储库中。有几个人和我一起参与主要项目,我是维护者。

在早期的项目中,我曾经手动将依赖项复制到 Git 工作树,添加一个指定我使用的版本的小文件。

现在这相当不舒服,因为我需要每天更新一个依赖项,并且经常自己为其贡献代码,大多数时候还需要对主项目进行更改。

我决定尝试使用 Git 子模块来进行管理。我越尝试它们,我就越沮丧。甚至看起来手动复制也许更好。

以下是我的一些担忧:

  • 我们不再能够通过单个命令获得一致的存储库状态(git checkout 现在需要 git submodule update --init)。
  • 我们无法正确使用一些 Git 工具(git archive 是最值得注意的)。
  • 我们无法看到主项目中子模块的状态更改/差异。
  • 正如我刚刚发现的那样, git submodule 不适用于 --git-dir--work-tree 选项,并要求将当前目录物理更改为“工作树的顶层”。

看起来,为了简化我们的子模块工作流程(即一个操作 == 一个命令),我们必须围绕 Git 编写一个相当厚的包装器。这很悲伤。

请注意,不能选择放弃 Git 或将子项目开发完全合并到主项目中。

也许我以错误的方式使用 git submodules ?有没有关于工作流程的好的教程?

即使您不知道正确的答案,也请大声说出来,但请分享我的担忧。 :-)

In my project I need to use third party code, stored in several Git repositories. My project is also stored in (separate) Git repository. There are several people working with me on the main project, and I'm the maintainer.

In earlier projects I used to copy dependencies manually to the Git working tree, adding a little file specifying version I use.

Now this is rather uncomfortable since I need to update daily one of dependencies, and often contribute code to it myself, most of the time coupled with changes into the main project.

I've decided to try Git submodules to do the management. The more I try them, the more frustrated I become. It even seems that manual copy is, perhaps, better.

Here are some of my concerns:

  • We're no longer able to get consistent repository state with a single command (git checkout now needs git submodule update --init).
  • We're not able to use some of the Git tools properly (git archive is the most notable).
  • We're not able to see the status changes / diffs into submodules from the main project.
  • As I've just found in a hard way, git submodule does not work with --git-dir and --work-tree options, and require physical change of current directory to the "toplevel of the working tree".

It seems that in order to streamline our submodules workflow (that is one operation == one command) we have to write a rather thick wrapper around Git. This is sad.

Note that it is not an option to move away from Git or to merge subproject development entirely into the main project.

Perhaps I'm using git submodules in a wrong way? Is there any good tutorial on the workflow?

Please speak up even if you don't know the proper answer, but do share my concerns. :-)

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

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

发布评论

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

评论(2

遗忘曾经 2024-08-15 20:14:22

您可能想尝试 git 子树alt 链接) 。我很幸运,在我的项目中使用了远程存储库和干净的(与 master 历史无关)分支。

You may want to try git subtree (alt link) instead. I’ve had a lot of luck with it, using both remote repos and clean (untied to master history) branches in my project.

神回复 2024-08-15 20:14:22

git 邮件列表上最近的一个帖子包含一个补丁,用于说明如何使用单个命令获得一致的存储库状态。它基本上在更改分支时调用 git submodule update。

http://thread.gmane.org/gmane.comp .version-control.git/130155/focus=130330

A recent thread on the git mailing list includes a patch for how to get a consistent repository state with a single command. It basically calls git submodule update when changing branches.

http://thread.gmane.org/gmane.comp.version-control.git/130155/focus=130330

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