0

I have an application which I am making

The App as usual have two parts

-> The frontend 
-> The Backend 

Both frontend and Backend are inside parent a folder which I initialised using git init.

ParentFolder 
--> Frontend 
--> Backend
// Git Initialisation is done on Parent folder

Now whenever I add module for frontend and backend and do git add, git commit, it is also committing the node module inside the frontend and backend.

[Question:] So i want git to ignore node modules folder in frontend and backend, So how can I achieve this?

Alwaysblue
  • 9,948
  • 38
  • 121
  • 210
  • 2
    Possible duplicate of [Git - Ignore node\_modules folder everywhere](https://stackoverflow.com/questions/29820791/git-ignore-node-modules-folder-everywhere) – f-CJ Oct 14 '18 at 16:06
  • Please add folder structure with node_modules mentioned. – Rishabh Agarwal Oct 14 '18 at 16:30

2 Answers2

2

Create a .gitignore file at the root of your project and target any node_modules folder.

.gitignore documentation

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected


Structure

Parent folder
   Frontend   (folder)
   Backend    (folder)
  .git        (folder)
  .gitignore  (file)

.gitignore file content

node_modules/
Quentin Veron
  • 3,079
  • 1
  • 14
  • 32
0

Using a .gitignore file will help you do this.

Considering you have the following structure:

->ParentFolder 
|-->Frontend 
|     |-->node modules
|
|---> Backend
|     |-->node modules

You can use the following lines in the .gitignore file created at the root of your project.

*/node_modules/
Rishabh Agarwal
  • 1,988
  • 1
  • 16
  • 33