How to git ignore ipython notebook checkpoints anywhere in repository

sapo_cosmico picture sapo_cosmico · Mar 10, 2016 · Viewed 50.8k times · Source

This is mostly a git question. I want to commit my ipython notebooks but gitignore the checkpoints.

The repo has multiple folders which each have ipython notebooks, therefore just ignoring a single directory does not solve it. I want to keep adding new folders with notebooks inside without worrying about it.

My hunch is that there must be a way to use some wildcard to gitignore anything that is in a folder that is called */.ipynb_checkpoints/ but haven't been able to figure it out.

So, how can I git ignore all ipython notebook checkpoints in a repository, wherever they are?

Answer

minrk picture minrk · Mar 11, 2016

If you add to .gitignore:

.ipynb_checkpoints

(no slashes anywhere), any file or directory in the repo with that name will be ignored. Paths are only checked if you include /.

From this answer you can also have a global gitignore for your computer:

git config --global core.excludesfile '~/.gitignore'
echo '.ipynb_checkpoints' >> ~/.gitignore