Step 1 : Create .gitignore
To create a .gitignore file, go to the root of our local Git, and create it :
$ touch .gitignore
Step 2 : Append extensions or directory name to .gitignore
Now open the file using a text editor. We are just going to add using wild expression.
# ignore ALL .log files
*.log
# ignore All directory named ipynb_checkpoints
.ipynb_checkpoints
*/.ipynb_checkpoints/*
Step 3 : Notice after commit .gitignore
If we have already pushed our code before, add .ipynb_checkpoints to our .gitignore. This will ensure that .ipynb_checkpoints will be ignored in the future but doesn't remove our old .ipynb_checkpoints.
We have to manually remove the cache in every folder in the respective branch. Go to the folder that has the .ipynb_checkpoints at first and do
git rm -r --cached .ipynb_checkpoints
Source from :
- https://stackoverflow.com/questions/35916658/how-to-git-ignore-ipython-notebook-checkpoints-anywhere-in-repository
- https://www.w3schools.com/git/git_ignore.asp?remote=github