본문 바로가기

Git

[gitignore] How to ignore files and directory in repository

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 :