.gitignore does not apply to the production


I use Manual Deploy and Start to deploy my static site using CLI. I use .gitignore file and have temp_directory and don’t want this directory to be deployed and published. but it always published

my gitignore file:


I proceeded according to this guide Manual Deploy and easily use netlify deploy --prod


hi there, sorry to be slow to reply.

is the gitignore file working for the other things mentioned?

Hi, that’s all right.
yes, it seems working for other files. I check .project and nothings deployed. that’s wired.

Greetings :wave:t2:

I don’t believe the netlify deploy command is Git-aware at all and it does not take into account any .gitignore file(s) — we can see some of the source behind the command here:

There isn’t any filtering or considerations for .gitignore files — the command deploys the full folder :thinking:

Hope that helps!


Hi, @Mikka. +1 to what @jonsully said. The file .gitignore is used by Git and not by the Netlify CLI tool. The Netlify CLI tool does not look at that file when deploying.

To resolve this, put only the files you want to deploy in the publish directory. You might write a custom script to do this.

If there are other questions, please let us know.

Yes.Sorry. That’s Right. By the way thanks