diff --git "a/009-\344\270\215\350\277\275\350\270\252Output.ipynb" "b/009-\344\270\215\350\277\275\350\270\252Output.ipynb" new file mode 100644 index 0000000000000000000000000000000000000000..639d398f1ad0cc9fa38861b0a160173c1d1524ce --- /dev/null +++ "b/009-\344\270\215\350\277\275\350\270\252Output.ipynb" @@ -0,0 +1,72 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 如何让 Git 不在追踪 `ipynb` 文件中的 Output\n", + "\n", + "参考 https://github.com/jupyterlab/jupyterlab-git/issues/392 中提到的 youtube 视频介绍,在 notebook 与 git 的配合使用过程中,可以通过 `nbstripout` 和 `nbconvert` 两个插件搭配使用,在 git 中添加一个过滤器,确保 git 只跟踪 input 的变化,而忽略 output 的变化\n", + "\n", + "具体步骤:\n", + "\n", + "1. pip install nbstripout\n", + "2. pip install nbconvert\n", + "3. 启动 nbstripout `nbstripout --install`\n", + "4. git add files\n", + "5. git commit files\n", + "6. git push files" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install nbstripout nbconvert" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!nbstripout --install" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!python -v" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" + }, + "kernelspec": { + "display_name": "Python 3.9.1 64-bit", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}