git uncommit node_modules

1. Create a .gitignore file: Create a file named ".gitignore" in the root directory of your project (if it doesn't already exist).

2. Edit the .gitignore file: Open the .gitignore file with a text editor, and add a line in the file to specify the file or directory to be ignored. In this case you can add the following line to exclude node_modules folder:

node_modules/

3. Save and submit the .gitignore file, then add the .gitignore file itself to the Git repository and submit it:

git add .gitignore
git commit -m "Add .gitignore file"

4. Commit other changes: Continue to use normal Git commands to add other files and changes to the commit:

git add .
git commit -m "Your commit message"

This way, when you run the git push command, the node_modules folder will not be included in the commit.

Note
If the node_modules folder has been submitted to the Git repository, you need to delete it from the repository by running the following command after adding rules to the .gitignore file:

git rm -r --cached node_modules

This will remove the committed node_modules folder from the Git repository, but keep a local copy. Then, make a new commit:

git commit -m "Remove node_modules from repository"

These steps will help you exclude the node_modules folder when committing code to the Git repository.

Guess you like

Origin blog.csdn.net/weixin_44582045/article/details/131627287