可以在单个仓库中为不同项目使用分支吗?

huangapple go评论49阅读模式
英文:

Can I use branch for different projects in single repo?

问题

我有一些具有独立代码的项目,但目的相似。我可以创建一个巨大的Git存储库,然后创建不同的分支来容纳不同的项目吗?
例如,我想创建一个名为"database"的存储库,并创建不同的分支来容纳MySQL、PostGres和ClickHouse的源代码。这有意义吗?

英文:

I have some projects with independent code, but similiar purpose. Can I create a giant git repo and create different branch to hold different projects?
For example I want to create a repo named database, and create different branches to hold source code of MySQL, PostGres and ClickHouse. Does it make sense?

答案1

得分: 2

以下是翻译好的部分:

  • git switch --orphan 用于创建新的孤立分支
  • get merge --allow-unrelated-histories 用于在具有不同根的分支之间进行合并
  • get worktree 用于在单独的文件夹中检出分支
  • git submodule 轻松处理指向相同存储库的子模块
英文:

Some git operations will be slower due to the size of such a repository, but it is perfectly fine.

Git even comes with a lot of built-in support for creating and working with repositories like this:

  • git switch --orphan for creating new orphan branches
  • get merge --allow-unrelated-histories for merging between branches with different roots
  • get worktree for checking out branches in a separate folder
  • git submodule easily handles submodules that point into the same repository

huangapple
  • 本文由 发表于 2023年2月16日 10:02:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75467149.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定