1. 安装jupytext文件,
python3 -m pip install jupytext --user;
2. 生成修改jupyter notebook配置文件
jupyter notebook --generate-config -y echo 'c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"' >> ~/.jupyter/jupyter_notebook_config.py
3. 将jupytext添加到对应路径中,export PATH=$PATH:/Users/XXXX/Library/Python/3.7/bin;
4. jupytext --to py abc.ipynb 生成对应的abc.py文件;
5. 将"jupytext": {"formats": "ipynb,py"}添加到jupyter notebook--jupyter界面--打开对应的abc.ipynb-编辑--编辑界面原数据的文件中。注意不要修改其它的配置;
这样.py与.ipynb文件就可以同步了。只要git管理.py文件即可。
参考文献:https://nextjournal.com/schmudde/how-to-version-control-jupyter