Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git ignore ipython notebook checkpoints anywhere in repository

People also ask

Where are Jupyter notebook checkpoints stored?

As a side note, the checkpoint file is located within a hidden folder named . ipynb_checkpoints . This folder is located within the same folder as the initial . ipynb file.

How do I ignore a file in Git?

Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

How do I ignore a folder in Git?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.

How do I use Gitignore?

You can create a . gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the . gitignore file in to your repository.


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

I would recommend to use **/*.ipynb_checkpoints/ in your .gitignore file.


Add to your .gitignore:

.ipynb_checkpoints
*/.ipynb_checkpoints/*

And you should be good to go.


Some times you may forget that you are already tracking the file in your git repository (as it was in my case). So you may have to untrack it first

git rm --cached Folder_with_ipynb/.ipynb_checkpoints/news-checkpoint.ipynb

and then add to your .gitignore the line:

*/.ipynb_checkpoints/*.ipynb