如何使用 Git 单独组织额外的项目材料?
我希望所有项目文件(例如源代码)都成为存储库的一部分。为简单起见,所有工作都在开发分支上完成。此外,我想包含其他项目材料,例如 pdf 文件。我不想将它们添加到开发分支。到目前为止,我想出了以下策略。
- 策略 1 是创建一个单独的分支 material 并添加 pdf。该分支与其父分支共享一些历史。
- 策略 2 适应了第一个策略,但也不时将 material 分支的提交合并到 development 分支中。 (我不想要这个,它是皮塔饼。)
- 策略 3 是创建一个 孤儿分支 不共享源的历史记录例如,代码。
- 策略 4 是遵循策略 1 或 3,并另外创建一个仅代表“主”存储库的 material 分支的子模块。如果可能的话,工作目录将同时显示development分支和material分支。
所有策略的缺点是,当我签出另一个分支时,我无法访问工作目录中的文件。
我怎样才能在开发分支上工作,同时在工作目录中获得材料可用?如果您更容易想象,材料也可以是文档。
编辑:在阅读 Seth Robertson 的答案后,我添加了策略 4。
I want all project files like source code to be part of the repository. For simplicity reasons all work is done on the development branch. Furthermore, I want to include additional project material like pdf files. I do not want to add them to the development branch. Until now I came up with the following strategies.
- Strategy 1 is to create a separate branch material and add the pdfs. The branch shares some history with its parent branch.
- Strategy 2 adapts the first strategy but also merges the commits of the material branch into the development branch from time to time. (I do not want this, and it is a pita.)
- Strategy 3 is to create an orphan branch that does not share the history of the source code, for example.
- Strategy 4 is to follow strategy 1 or 3 and additionally create a submodule that represents only the material branch of the "main" repository. If this is possible the working directory would show the development branch and the material branch at the same time.
The disadvantage to all strategies is that I can not access the files in the working directory when I checked out another branch.
How can I work on the development branch and at the same time have the material available in the working directory? If it is easier to you to imagine, the material could also be the documentation.
Edit: I added strategy 4. after reading Seth Robertson's answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,您可以将 pdf 拆分到单独的存储库中,并使用 gitslave 或 git-submodules 之类的内容来链接这两个项目一起。
这个想法的一个扩展是,当使用 git-submodules (不是 gitslave)时,你可能能够真正将“其他存储库”设置为不同分支上的本地存储库(我不明白 git 如何区分这一点)从其他情况来看,如果您实际上使用相同的存储库而不是从主上游克隆,则锁定可能是例外)。
当然,使用 git-submodules,您可能(或可能不会)在合并 pdf 存储库的 SHA 时遇到问题。 gitslave 就不会有这个问题。
Well, you could split the pdfs into a separate repository and use something like gitslave or git-submodules to link the two projects together.
One extension of this idea is, when using git-submodules (not gitslave), is that you might be able to actually make the "other repository" your local repository on a different branch (I don't see how git could tell this apart from some other case—with the possible exception of locking if you actually use the same repo instead of cloning from the master upstream).
Of course, with git-submodules you might (or might not) have problems with merging the SHA of the pdf repo. gitslave would not have that problem.