我可以使用 git 子模块来管理单个文件和目录吗?
我有一个复杂的存储库,有时代码段之间的逻辑边界跨越目录边界。有时目录 X 中的单个文件确实需要与目录 Y 中的文件一起使用。
例如,假设我有一个如下所示的中央存储库:
a/foo
a/bar
b/baz1
b/baz2
...并且我希望我的本地存储库以 a/*< /code> 和
b/baz1
,但不是 b/baz2
。
(是的,长期解决方案是移动文件,但是当我正在进行重构时,我需要适当地对文件进行版本控制。)
我可以使用 git 子模块来处理一组包含一些目录和其他一些随机文件?我该怎么做?
I have a complex repository where sometimes the logical boundaries between code segments crosses directory boundaries. Sometimes a single file in directory X really needs to go with files in directory Y.
E.g., pretend I have a central repo that looks like this:
a/foo
a/bar
b/baz1
b/baz2
...and I want my local repository to end up with a/*
and b/baz1
, but not b/baz2
.
(Yes, the long term solution is to move the files, but while I am working on that refactoring, I need to version-control the files appropriately.)
Can I use git submodule to work on a set of code that includes some directories and some other random files? How would I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,Git“子模块”功能仅限于子目录及其包含的所有文件。
No, the Git "submodule" feature is limited to subdirectories and all the files they contain.
Gists 充当迷你存储库,甚至包括修订历史记录。您可以将单个文件放在 gist.github.com 上并将它们添加为子模块。
即使隐藏的要点是公开的——记住这一点也很重要。使用要点可能并不适合所有情况。
Gists act as mini repositories and even include revision history. You can put your single files on gist.github.com and add them as submodules.
Even if hidden gists are public -- it's important to keep that in mind. Using gists may not be appropriate in all situations.