在 Windows 上,我们有 root\folder1
、root\folder2
、root\folder3
。
在 Linux 上,我们有 root/folder1/folder2
、root/folder1/folder3
我强烈建议不要使用子模块或子树。
还有其他解决方案吗?创建一个分支并将文件重新排列为 Linux 结构是否可行?分支之间的 merge 是否有意义?
编辑
我读了更多的书,尤其是关于分支工作流程的书。我现在正在重新考虑 NOT submodules 声明。我担心包含子模块的日常开发人员存储库以及似乎需要的复杂性。但是,我认为开发人员不需要子模块,他们可以通过嵌入式存储库满足需求。
假设 folder 1
、folder 2
和 folder3
是独立的 git 存储库 - repo 1
、 repo 2
和 repo 3
。在 Windows 上,3 个存储库是分开的。在 Linux 上,folder 1
是 repo 1
,folder1/folder 2
是 repo 2
,等等。
如果我在 folder 1
中并且 folder 2
中有更改,git add .
是否会不包括 文件夹
2 改变了吗? git 在看到另一个 .git
时会停止吗?
可能有 2 个单独的裸存储库用于构建,其中包括 3 个存储库作为适用于 Windows 和 Linux 的适当配置中的子模块。然后可以在此处管理发布分支。但是在 repo 1、2 和 3
中看到了什么分支?有没有人尝试过这样的事情?效果好吗?
最佳答案
在符号链接(symbolic link)旁边 mentioned通过 mvp (注意:您可以有 symlink on Windows 7+ too ,另请参阅“Git Symlinks in Windows ”),这将是一个部署问题:
即:你会:
- 您的常规本地克隆
- 具有正确结构的该克隆的副本
- 一种将在该副本中所做的任何修改差异化/导入回常规 git 存储库的方法
...所以是的,保持通用目录结构仍然是最简单的解决方案。
If I'm in
folder 1
and there are changes infolder 2
, will agit add .
not include thefolder 2
change?
不,它只会考虑文件夹 1
任何部分的更改器,除了 文件夹 2
内容。
Does git stop when it sees another .git?
没错。
There could be 2 separate bare repositories for building which includes the 3 repos as submodules in the appropriate configuration for Windows and Linux
注意:一个裸仓库不能包含另一个仓库,因为该仓库没有工作树来包含……任何东西。
与子模块相反,嵌套的 repo 根本不会记录在父 repo 的分支中。
I suspect subtree is a better fit for us.
是的,subtree (part of git since 1.7.11)将涉及 2 个存储库:一个用于 Windows,一个用于 Linux。
每个人都会聚合具有正确结构的子树 repo 协议(protocol)。
关于git - 如何使用Git在不同的平台上有不同的工作目录结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17160793/