Mathematica 笔记本的版本控制 [英] Version control of Mathematica notebooks

查看:16
本文介绍了Mathematica 笔记本的版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当然,Mathematica 笔记本是纯文本文件——期望它们与版本控制系统(在我的例子中是 git,尽管我怀疑特定系统很重要)一起玩似乎很合理.但事实是,任何 .nb 文件都充满了缓存信息、时间戳和其他各种元数据.一大堆.

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.

这意味着有限的版本控制是可能的——提交和回滚工作正常.然而,合并是一场灾难.Mathematica 不会打开带有合并标记的文件,文本编辑器也无法查看 .nb 文件.

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.

这很容易被选项检查器禁用.在 Mathematica 菜单中,转到 格式Option Inspector...,在左上角将 scope 下拉列表设置为 Selected Notebook 并搜索 FileOutlineCache在搜索字段中.将选项设置为 False 并保存您的笔记本,您应该已全部设置完毕.

This is easily disabled with the Option Inspector. In the Mathematica menu, go to FormatOption 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆