0

I am setting up am Angular.js project from scratch. And I would like to keep it on Github inside a repository.

I have a simple question but I couldn't find a comprehensive answer for it. After establishing the project basic scaffold, and installing some node modules with NPM, there are many libraries, node-modules and etc in project structure. Also there are files of the framework for example Sails framework. Since a developer can install them by running npm install, which files should I push into the repository? Which ones don't need to be pushed?

The problem is, Source tree shows all new files as not staged, and I am confused which one I should exclude, which I should commit.

2 Answers 2

1

From personal experience, 2 types of files can be ignored in git

  1. 3rd party libraries, which can be installed using npm/bower etc.
  2. Generated files, like css generated from less, minified js files, etc.
Sign up to request clarification or add additional context in comments.

Comments

1

which files should I push into the repository?

Any files related to your application that contain business logic, routing, or other files that you've added to the project that are required for your app to run.

Which ones don't need to be pushed?

You should add node_modules to your .gitignore file. In almost all scenarios it would be unnecessary to include installed packages because your package.json maintains a list of packages to install when calling npm install.

If you're not sure about where to start with a .gitignore file, this is the defacto Node.js .gitignore file that is generated by GitHub & many popular IDE's. Just add that file to your project folder and git will automatically detect it, you should include your .gitignore as part of your repository files.

Additionally, if you're using Bower for front-end package management, you should add your bower.json to your repository and add the bower_components directory to your .gitignore.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.