问题描述
我读了很多关于git submodule应该是多么糟糕的问题,但我不确定这是否只是感觉它受到限制或者它有严重问题的人的呻吟(特别是关于我的用例)。 p>
我只是希望在我的回购中包含不同的回购,例如
网站/
libs /
js /
fs-slides [external]
fs-dialog [external]
,并且可以轻松更新这些回购协议。据我所知,从回购中只包含一个文件是不太可能的,对吧? (但没关系。)
我应该使用子模块吗?
或者是否有任何问题?或者是子树更容易?
子模块非常适合您的情况,尤其是因为您不介意包含这些subrepos在他们自己的子目录中。
使用子模块的主要严重问题是在进行更新时更新它们,如:
如果您在子模块中提交时忘记设置分支,则所述提交将在分离的HEAD上进行,并且正在进行的更改将在下一个 git子模块更新
(如果为子模块回购激活,您可以通过
reflog
获取它们)。
I just want to include different repos into my repo like this
website/
libs/
js/
fs-slides [external]
fs-dialog [external]
Should I use submodules for this?
Or are there any problems with it? Or is subtree much easier?
The main serious issue you could have using submodules is when updating them while having updates in progress, as described in "how exactly does git submodule work":
If you forget to set a branch when making commits in a submodules, said commits will be made on a detached HEAD, and those changes in progress will be lost at the next
git submodule update
(you can get them back through the reflog
, if activated for your submodule repo).
Then, as Michael comments, and as I detail in the link above, you need to push the submodule to its own upstream before commit and pushing the parent repo (to avoid pushing unpublish submodule commits)
这篇关于Git使用子树或子模块来管理外部资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!