Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.ipynb filter=nbstrip
*.ipynb filter=ipynb_stripout
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
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.

git add .gitattributes
git commit -m "Added ipynb_stripout. See https://github.com/jond3k/ipynb_stripout" .gitattributes
6 changes: 1 addition & 5 deletions nbstripout → ipynb_stripout
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"""
Expand Down
4 changes: 0 additions & 4 deletions nbstripout_v3 → ipynb_stripout_v3
Original file line number Diff line number Diff line change
@@ -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
Expand Down