Search code examples
djangogitgitignore

Ignoring a folder inside static files using gitignore in a Django project


I have a folder inside the static directory of an app in a Django project. Lets call this special_folder. It contains some static files that I do not want to commit to Git. The project directory looks something like this:

myproject
|
+-- manage.py
|
+-- .gitignore
|
+-- myapp
    |
    +-- static
        |
        +-- special_folder

Now, if I want to ignore this folder for Git, do I need to add something like the following line to the .gitignore file:

myapp/static/special_folder/

Is this the right approach? Or should I just add special_folder/? Thanks for any help.


Solution

  • All paths are relative to the .gitignore.

    Based on your folder structure and location of .gitignore file you are correct. The below should work.

    myapp/static/special_folder/
    

    Refer Pattern Format.

    HTH