git 存储库中的分支不变目录
有没有办法让 git 存储库中的目录在所有分支中始终相同?
我想到的场景如下:考虑您正在开发一个项目/论文,您正在其中进行大量实验(即创建一个分支,尝试一些东西/进行测量/统计,通常不会将其合并回主版本)加上您编写了一篇文档/论文,其中您希望获得所有(包括实验)分支的内容/结果。来回切换分支当然适用于实验本身,但对于您的文档/论文,您实际上始终只需要一个当前版本。
另一种方法是将您的文档放入一个单独的分支(就像某些项目所做的那样),但我个人觉得每当您想向文档/论文添加某些内容时总是进行切换很烦人。
我也可以有两个存储库,但这在某种程度上违背了我对存储库的直觉,因为包含有关项目 XY 的所有内容...
Is there a way to make a directory in a git repository always the same in all branches?
The scenario which I have in mind is the following: consider you are working on a project/thesis where you are experimenting a lot (i.e. creating a branch, try something out/do measurements/statistics, typically not merge it back to master) plus you write a documentation/thesis where you want to have content/results from all (incl. experimental) branches. Switching back and forth the branch of course works for the experiments itself, but for your doc/thesis you really only want a single current version at all times.
An alternative would be to put your doc into a separate branch (like some projects do), but I personally find it annoying to always switch whenever you want to add something to your doc/thesis.
Also I could have two repositories, but that somehow goes against my intuition of a repository as the thing that contains all stuff about project XY...
查看简单但笨重的 git 子模块 或更光滑但更复杂的 git 子树。
它们允许您将单独的存储库嵌入到您的存储库中,这可能会满足您的目的。
Take a look into the simple but clunky git submodule or the slicker but more complicated git subtree.
They let you embed a separate repository into your repository, which might serve your purpose.