Search code examples
node.jsgitexpressnodemon

Is it possible to run node server in Express with only git-tracked files?


I would like to run my Express app but only with files that are currently tracked in Git. For example, here is my current status of Git (git status):

On branch master
Untracked files:
 (use "git add <file>..." to include in what will be committed)

    blogs/test_announcement.md
    public/css/bootstrap-theme.min.css
    public/css/bootstrap.min.css
    routes/twitter.js

nothing added to commit but untracked files present (use "git add" to track)

However, when I tried to run the server (I use nodemon), it seems that there is no way to ignore the untracked files. This makes the blog test_announcement displayed on the website.

Ultimately, I'm going to push my local files managed under git to a remote PaaS so there wouldn't be a problem on the production. However, it is pretty stressful to see the untracked files in development phase.

So is there any possible way to ignore those files locally?


Solution

  • My suggestion is add those files to a separate git branch and checkout a different branch when you want to test without them. For example, keep your master branch clean but you could have a private local-drafts branch with not-to-be-published files.