Mathematica笔记本的版本控制 [英] Version control of Mathematica notebooks
问题描述
这意味着有限的版本控制是可能的 - 提交和回滚工作正常。不过,合并是一种灾难。 Mathematica不会打开带有合并标记的文件,并且文本编辑器无法通过.nb文件。
有没有人有幸把一个文件版本控制下的笔记本?如何?
建议禁用文件大纲缓存,这是您在查看带有文本编辑器的笔记本。正如您发现的那样,如果多方正在编辑同一个笔记本电脑,它可能会导致合并冲突。
使用Option Inspector很容易禁用此功能。在Mathematica菜单中,转到格式→在左上方的范围下拉列表中选择 FileOutlineCache
在搜索字段中。请将该选项设置为False并保存您的笔记本电脑,并且应该全部设置好。
请注意,这可能会使打开笔记本电脑变慢一点,但除非笔记本电脑相当大,您可能不会注意到其中的差异。
Mathematica notebooks are, of course, plaintext files -- it seems reasonable to expect that they should play nice with a version-control system (git in my case, although I doubt the specific system matters). But the fact is that any .nb file is full of cache information, timestamps, and other assorted metadata. Scads of it.
Which means that limited version control is possible -- commits and rollbacks work fine. Merging, though, is a disaster. Mathematica won't open a file with merge markers in it, and a text editor is no way to go through a .nb file.
Has anyone had any luck putting a notebook under version control? How?
It's recommended to disable the file outline cache, which is the metadata you're referring to when you look at the notebook with a text editor. As you discovered, it can cause merge conflicts if multiple parties are editing the same notebook.
This is easily disabled with the Option Inspector. In the Mathematica menu, go to Format → Option Inspector..., in the top-left set the scope dropdown to Selected Notebook and search for FileOutlineCache
in the search field. Set the option to False and save your notebook, and you should be all set.
Note that this can make opening notebooks a little slower, but unless the notebook is rather large, you probably won't notice the difference.
这篇关于Mathematica笔记本的版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!