在一个GIT存储库中维持多个无关的历史
我的用例:我想创建几个小示例程序,然后将它们全部存储在示例/
repo中。当某人结帐示例/a
时,我希望他们能够运行git log
,并且仅查看与a/
的提交b/
c/
d/
和e/
的大量无关提交。
我了解git suppodule
或git subtree
可以做到这一点,但是所有这些都需要单独的存储库,我认为不值得创建一个或两个文件的50个不同的存储库每个。我希望他们所有人都活在一个仓库中,但要保持不同的历史。这可能吗?
My use case: I want to create several small example programs, and store them all in an examples/
repo. When someone checkouts examples/a
, I would like them to be able to run git log
and see only the commits relevant to a/
without the large number of unrelated commits for b/
c/
d/
and e/
.
I understand that git submodule
or git subtree
can do this, but those all require separate repos and I don't think it is worth creating 50 different repos of one or two files each. I would like them to all live in one repo, but maintain different histories. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,绝对。您可以在存储库中获取或创建您喜欢的任何历史记录结构。在
示例中制作一个新的空分支的最简单方法
是用您的第一组内容修改存根提交。
我还定期使用此操作来携带“合并子模型”,始终需要但与其他项目共享的实用程序代码,
git subpodule
命令是明显的可选,但是很容易将其用于使用此设置,只是告诉它,您已经克隆了上游模块,例如,在utils
分支中带有的“ utils”历史记录,我将在克隆上,
in
in
.gitmodules
,这就是所有设置的机械。Yes, absolutely. You can fetch or create any history structures you like in a repository. Easiest way to make a new empty branch in
examples
isand amend the stub commit with your first set of content.
I also use this regularly to carry "incorporated submodules", utility code that's always required but shared with other projects, the
git submodule
command is distinctly optional but it's easy to finagle it into working with this setup, just tell it you've already cloned the upstream module, for e.g. a "utils" history carried in theutils
branch I'llon clone, with
in
.gitmodules
and that's the machinery all set up.