'Netlify dont deploy specific folder or files

I have a git a repository set up with CD on Netlify. The site itself is 4 files, but I have some other files I'd like to add to the repository that I don't want deployed. Is there a way to deploy only certain files with a deployment? Or only a specific folder?

My site only requires an http server, there's not an npm, jekyll, or hugo install. It's just the deployment of 4 files.



Solution 1:[1]

If you put the files in a specific folder you can set the Base Directory in your Build & Deploy settings to that directory and it will ignore the other files/folders not in that directory.

Solution 2:[2]

According to the docs, this is a bit more involved than just setting the base repo:


For this next example, consider a monorepo project set up like this, where blog-1 is the base directory.

repository-root/
?? package.json
?? workspaces/
   ?? blog-1/
   ?  ?? package.json
   ?  ?? netlify.toml
   ?? common/
   ?  ?? package.json
   ?? blog-2/
      ?? package.json
      ?? netlify.toml   

The following ignore command example adapts the default behavior so that the build proceeds only if there are changes within the blog-1 or common directories.

[build]
  ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../common/"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt Busche
Solution 2 joelostblom