0

Here is a question about Heroku and its version control system.

Far from being an expert in VCS, I may be asking something quite basic. In that case just forgive me. Here is the issue.

  • When I go and edit a file in my project and save it, say index.js for instance. I can then run the following commands in the terminal (as I have learned to do it in some tutorial):

    $ git add . && git commit -m "my-nice-project" && git push heroku master

And that does the job of updating the app on the server as I expect.

  • If I repeat the same comment again:

    $ git add . && git commit -m "my-nice-project" && git push heroku master

I get a message saying:

On branch master
Your branch is up-to-date with 'heroku/master'.
nothing to commit, working tree clean

$ 

Here also I get what I expect, since I did not touch anything on the project.

But what follows is not a situation I expect, and I'd be glad if someone could help me clarify things up.

I run this:

$ npm outdated

to check for old packages; then I run:

$ npm update

to update old packages; and I can see with my eyes that something has changed in the tree structure of the project.

Now here when I run:

$ git add . && git commit -m "my-nice-project" && git push heroku master

I still get a message saying:

On branch master
Your branch is up-to-date with 'heroku/master'.
nothing to commit, working tree clean
$ 

Why is that? Things have changed locally, I would expect an update of the app on the server. What am I missing?

Michel
  • 10,303
  • 17
  • 82
  • 179

1 Answers1

1

It's mainly caused the npm packages are not version controlled by git.

You can check your git repo, if the content of .gitignore contains the file or path that the npm package located.

And if you want the npm package is version controlled by git, you can remove the content about the package name or path. Then git will track the package's changes.

Whether add node_modules in git version control is depend on how you used the npm package:

For most cases, node_modules is ignored by .gitignore.

But if need to lock down the package, you can add it in git version control.

More details, you can refer node_modules in git and Should I check in node_modules to git when creating a node.js app on Heroku.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • Indeed node_modules is inside .gitignore, I here have a reason to remove it. But I suppose npm might also have had good reasons to place it there. Any particular advice? – Michel Aug 08 '17 at 04:20
  • 1
    I added the part **whether add node_modules in git version control or not** in my answer. You can decide which is your situation. – Marina Liu Aug 08 '17 at 04:37