I am a data scientist and I do a lot of prototyping in jupyterlab. The problem is jupyterlab autosaves a lot of checkpoint files and when I do git add -A this will rope them in as well forcing me to either add more (which can be annoying if I've generated a bunch of image files of plots that I want to keep) or to remove them to the commit before running git commit and pushing. How can I add a general block on all file containing this substring .ipynb_checkpoints
so for instance none of the checkpoint files will be included in this list:
new file: .ipynb_checkpoints/High_IEG_expressing_cells-checkpoint.Rmd
# modified: DGC_Cck_to_Malat1_BehaviouralAxis.Rmd
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/ExcitatorySampleCorrelation-checkpoint.png
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/ExcitatorySamplesAllGenesExpression-checkpoint.png
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/Filterddata_ExcitatorySampleCorrelation-checkpoint.png
# modified: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/Pavlab_remotememory_DEG_analysis-checkpoint.ipynb
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/RemoteMemoryMarkersExpressionSampleLevel-checkpoint.png
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/pseudobulk_sample_corrrealtionmatrix-checkpoint.jpeg
# new file: EngramCellClassifier/Chen2020_GSE152632/.ipynb_checkpoints/test-checkpoint.jpg
# new file: EngramCellClassifier/Chen2020_GSE152632/ExcitatorySampleCorrelation.png
# new file: EngramCellClassifier/Chen2020_GSE152632/ExcitatorySamplesAllGenesExpression.png
# new file: EngramCellClassifier/Chen2020_GSE152632/Filterddata_ExcitatorySampleCorrelation.png
# modified: EngramCellClassifier/Chen2020_GSE152632/Pavlab_remotememory_DEG_analysis.ipynb
# new file: EngramCellClassifier/Chen2020_GSE152632/RemoteMemoryMarkersExpressionSampleLevel.png
# new file: EngramCellClassifier/Chen2020_GSE152632/pseudobulk_sample_corrrealtionmatrix.jpeg
# modified: High_IEG_expressing_cells.Rmd
You first need to create a .gitignore
file. Once you have done this you can add .ipynb_checkpoints
to the .gitignore
.
To do this open Git Bash and navigate to the root folder.
Then use the command touch .gitignore
. This creates the .gitignore
file.
Once the file has been created open it (it should be a text file) and add the text:
.ipynb_checkpoints
Save the file.
In Git Bash make sure you are in the correct directory, then use the command git add .gitignore
. Followed by git commit -m "YOUR COMMENT HERE"
. Then git push
. This should then ignore all files in the .ipynb_checkpoints folder.
To ignore them globally a solution has been posted here.
Hope this helps.
N.B. This is also a helpful article https://www.freecodecamp.org/news/gitignore-file-how-to-ignore-files-and-folders-in-git/