简体   繁体   中英

Ignoring a folder to commit in git

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?

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/

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM