From 74c27261da0106e7ac43b1c453436654c38854a7 Mon Sep 17 00:00:00 2001 From: Jon Davey Date: Fri, 4 Sep 2015 13:38:15 -0700 Subject: [PATCH 1/4] added new docs, rebranded and fixed deprecation warning --- .gitattributes | 1 - README.md | 39 +++++++++++++++++++----------- nbstripout => ipynb_stripout | 6 +---- nbstripout_v3 => ipynb_stripout_v3 | 4 --- 4 files changed, 26 insertions(+), 24 deletions(-) delete mode 100644 .gitattributes rename nbstripout => ipynb_stripout (78%) rename nbstripout_v3 => ipynb_stripout_v3 (82%) diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 472d2aa..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.ipynb filter=nbstrip diff --git a/README.md b/README.md index 1185d5a..d39239e 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,31 @@ -ipynb_template -============== +# ipynb_stripout -Template for creating a new git repo for an ipython notebook +Output cells make it difficult to manage iPython notebooks under Git. Diffs become noisy and merge conflicts become common. -1. Clone this repository -1. Rename the directory to something meaningful +This has been adapted from cfriedline's [ipynb_template](https://github.com/cfriedline/ipynb_template) and minrk's original [gist](https://gist.github.com/minrk/6176788) with the goal of making output stripping as easy as possible. -1. Make sure `nbstripout` is in your path and chmod +x +## 1) Install (OS X) -1. Add the following to your .gitconfig: +First you need to install the `ipynb_stripout` script. Run the following from your terminal: - [filter "nbstrip"] - clean = /home/cfriedline/bin/nbstripout - smudge =cat - required + wget -O /usr/local/bin/ipynb_stripout "https://raw.githubusercontent.com/jond3k/ipynb_stripout/master/ipynb_stripout" + chmod +x /usr/local/bin/ipynb_stripout -1. create a new github repo and change the origin in `.git/config` - - git remote set-url origin git@github.com:cfriedline/[new_repo].git +## 2) Configure git + +To make it optionally available to all your git repositories: + + git config --global filter.ipynb_stripout.clean ipynb_stripout + git config --global filter.ipynb_stripout.smudge cat + git config --global filter.ipynb_stripout.required + + +## 3) Add to repository + +Go to the root of the repository you want to add it to and `.gitattributes` with the following line: + + echo "*.ipynb filter=ipynb_stripout" >> .gitattributes + +Now you can commit the attributes. __Note that all other devs will need to follow these steps!__ + + git commit -m "Added ipynb_stripout. See https://github.com/ipynb_stripout/ipynb_stripout" .gitattributes \ No newline at end of file diff --git a/nbstripout b/ipynb_stripout similarity index 78% rename from nbstripout rename to ipynb_stripout index 7e4c88f..6507689 100755 --- a/nbstripout +++ b/ipynb_stripout @@ -1,10 +1,6 @@ #!/usr/bin/env python """strip outputs from an IPython Notebook -Opens a notebook, strips its output, and writes the outputless version to the original file. - -Useful mainly as a git pre-commit hook for users who don't want to track output in VCS. - This does mostly the same thing as the `Clear All Output` command in the notebook UI. Adapted from rom https://gist.github.com/minrk/6176788 to work with @@ -15,7 +11,7 @@ import sys #You may need to do this for your script to work with GitX or Tower: #sys.path.append("/Users/chris/anaconda/envs/conda/lib/python2.7/site-packages") -from IPython.nbformat import v4 +from nbformat import v4 def strip_output(nb): """strip the outputs from a notebook object""" diff --git a/nbstripout_v3 b/ipynb_stripout_v3 similarity index 82% rename from nbstripout_v3 rename to ipynb_stripout_v3 index 5c2bfb8..21a61a4 100755 --- a/nbstripout_v3 +++ b/ipynb_stripout_v3 @@ -1,10 +1,6 @@ #!/usr/bin/env python """strip outputs from an IPython Notebook -Opens a notebook, strips its output, and writes the outputless version to the original file. - -Useful mainly as a git pre-commit hook for users who don't want to track output in VCS. - This does mostly the same thing as the `Clear All Output` command in the notebook UI. Adapted from rom https://gist.github.com/minrk/6176788 to work with From e7b4bb3de3930bf56e003116bd922de199da52a5 Mon Sep 17 00:00:00 2001 From: Jon Davey Date: Fri, 4 Sep 2015 13:42:04 -0700 Subject: [PATCH 2/4] Added ipynb_stripout. See https://github.com/ipynb_stripout/ipynb_stripout --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..55e1ec6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.ipynb filter=ipynb_stripout From 8e7be4e6025feec0eb1e2d4eaf0cca10b4d61826 Mon Sep 17 00:00:00 2001 From: Jon Davey Date: Fri, 4 Sep 2015 13:42:46 -0700 Subject: [PATCH 3/4] fixed readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d39239e..7cb42e3 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,5 @@ Go to the root of the repository you want to add it to and `.gitattributes` wit Now you can commit the attributes. __Note that all other devs will need to follow these steps!__ - git commit -m "Added ipynb_stripout. See https://github.com/ipynb_stripout/ipynb_stripout" .gitattributes \ No newline at end of file + git add .gitattributes + git commit -m "Added ipynb_stripout. See https://github.com/jond3k/ipynb_stripout" .gitattributes \ No newline at end of file From ae8c56091fce1ce525efd5cad8eb28c8760f9596 Mon Sep 17 00:00:00 2001 From: Jon Date: Sun, 6 Sep 2015 15:53:10 -0700 Subject: [PATCH 4/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7cb42e3..ecd2e48 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Go to the root of the repository you want to add it to and `.gitattributes` wit echo "*.ipynb filter=ipynb_stripout" >> .gitattributes -Now you can commit the attributes. __Note that all other devs will need to follow these steps!__ +Now you can commit the attributes. git add .gitattributes - git commit -m "Added ipynb_stripout. See https://github.com/jond3k/ipynb_stripout" .gitattributes \ No newline at end of file + git commit -m "Added ipynb_stripout. See https://github.com/jond3k/ipynb_stripout" .gitattributes