Git子模块工作流程 [英] Git submodules workflow

查看:136
本文介绍了Git子模块工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



在之前的项目中,我曾经手动将依赖关系复制到Git工作树上,一个小文件,指定我使用的版本。



现在这很不舒服,因为我需要每天更新一个依赖项,并且经常为自己贡献代码,大部分时间加上主项目的变化。

我决定尝试Git子模块来进行管理。我尝试的越多,我就越失望。甚至似乎手工复制也许更好。



以下是我的一些担忧:


  • 我们不再能够通过一个命令获得一致的存储库状态( git checkout 现在需要 git submodule update - 初始化)。

  • 我们无法正确使用某些Git工具( git archive 是最值得注意的)。

  • 我们无法看到来自主项目的子模块的状态更改/差异。

  • 正如我刚刚发现的那样, git submodule 不适用于 - git-dir - work-tree 选项,并且需要将当前目录的物理更改添加到工作树的顶层。



看来,为了简化我们的子模块工作流程(这是一个操作==一个命令),我们必须写一个相当厚Git周围的包装。这是令人伤心的。



请注意,它不是一个可以从Git中移除或将子项目开发合并到主项目中的选项。



也许我以错误的方式使用 git submodules ?是否有任何关于工作流程的良好教程?



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

解决方案

您可能想试试 git subtree alt link )。我有很多运气,在我的项目中使用远程回购和清理(解开 master 历史)分支。


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

解决方案

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.

这篇关于Git子模块工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆